ProgrammingModerate
Keys {4, 7, 2, 9, 6, 1} are split into the even keys first and then the odd keys, keeping each group in input order. What is the result?
- A. 2 4 6 1 7 9
- B. 4 2 6 7 9 1
- C. 4 7 2 9 6 1
- D. 2 4 6 7 9 1
Correct answer: B. 4 2 6 7 9 1
A stable partition keeps the relative order inside each group. The evens 4, 2, 6 come first, then the odds 7, 9, 1.
More C Programming questions
- Records (P,5), (Q,9), (R,9), (S,3) are scanned with if (s.score >= best.score) best = s; starting from the first record. Which name is kept?
- Records (Raj,30), (Ana,25), (Raj,22), (Ana,40) are sorted first by age with a stable sort, then by name with another stable sort. What is…
- A swap-based selection sort is run on the records (A,2), (B,2), (C,1) using the key only. What is the final order?
- Upper bound: in the sorted keys 1, 3, 5, 5, 5, 8, 9 (0-based), what index does bisectright / upperbound return for x = 5?
- To find the k-th largest of 10^6 records by score, which approach is correct and fast enough?
- To find duplicate keys among 2 x 10^5 records, which method is correct and fast enough?