ProgrammingModerate
The median of the sorted keys 2, 4, 6, 8 with integer division is which value?
- A. 4
- B. 6
- C. 5
- D. 4.5
Correct answer: C. 5
With an even count the median is the average of the two middle values, (4 + 6) / 2 = 5 with integer division.
More C Programming questions
- 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…
- Which sort is stable and runs in O(n log n) worst case, suitable for struct arrays that must keep equal-key order?
- How many records remain after a struct array of 7 records is filtered to drop those with a key equal to the previous key, when the array…