Quick sort always chooses the last element as the pivot. Which input causes its worst-case O(n²) running time?
Correct answer A. An array that is already sorted
Subject / 929 questions
Page 27 of Programming multiple-choice questions with answers. Tap an option to check yourself.
Page 27 of 47
Correct answer A. An array that is already sorted
Correct answer B. [3, 1, 4, 8, 9, 7]
Correct answer A. It is stable and runs in O(n log n) time in every case, but needs O(n) extra space for arrays
Correct answer B. Heap sort
Correct answer B. O(n + k)
Correct answer A. 5, 10, 30, 25, 55, 70, 60, 40
Correct answer A. 30, 10, 50, 20, 40, 60
Correct answer D. Inorder
Correct answer D. 4
Correct answer C. 60
Correct answer D. O(log n)
Correct answer A. −1, 0 or +1
Correct answer A. A single left rotation; 20 becomes the root
Correct answer B. A left-right double rotation (left rotation at 10, then right rotation at 30)
Correct answer A. m − 1
Correct answer C. All data records are stored in the leaves, and the leaves are linked for sequential access
Correct answer B. [1, 4, 3, 10, 8, 7]
Correct answer C. [9, 4, 5, 1, 3, 2]
Correct answer A. 2i + 1 and 2i + 2
Correct answer C. O(n)