ProgrammingModerate
A histogram of sorted keys [1, 1, 2, 2, 2, 3] counts the adjacent equal pairs. How many such pairs are there?
- A. 3
- B. 2
- C. 4
- D. 5
Correct answer: A. 3
The pairs (1,1), (2,2) and (2,2) are adjacent and equal, giving 3.
More C Programming questions
- 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…
- Sorting 2 x 10^6 structs with qsort in C takes about how many comparisons?
- A list of records must be kept sorted while new records arrive one at a time. Which structure gives the best total cost for 10^5 inserts…