ProgrammingModerate
Two sorted struct arrays of sizes n and m are merged into a new array. How many elements does the merged array hold?
- A. max(n, m)
- B. n x m
- C. n + m
- D. n + m - 1
Correct answer: C. n + m
A merge keeps every element of both inputs, so the output has n + m elements.
More C Programming questions
- A struct array of n records is sorted by key. The code stores a record index inside each record before sorting, so that it can recover the…
- A histogram of sorted keys [1, 1, 2, 2, 2, 3] counts the adjacent equal pairs. How many such pairs are there?
- The largest gap between consecutive values of the sorted list 1, 4, 9, 16 is which value?
- The median of the sorted keys 2, 4, 6, 8 with integer division is which value?
- In the keys 3, 1, 3, 2, 1, the mode (most frequent key) is needed. With ties, the smallest key wins. Which is the mode?
- Records with a name and a score are stored in an array and sorted with a comparator that compares the names with strcmp. Which field…