UGC NET Paper 2 (Computer Science)Hard
In quicksort, if the recursive call is always made on the smaller of the two partitions first, the worst-case auxiliary stack depth is:
- A. O(log n)
- B. O(n)
- C. O(n log n)
- D. O(1)
Correct answer: A. O(log n)
Each pending recursive call on the stack is for a sub-array at most half the size of its parent, so the stack depth is bounded by log2 n even though the total running time can still be Theta(n^2).
Practise more UGC NET Computer Science and Applications questionsUGC NET Computer Science and Applications: notes and key points
More UGC NET Computer Science and Applications questions
- Which of the following NP-complete problems is only weakly NP-complete, i.e. solvable in pseudo-polynomial time?
- The maximum possible height of a red-black tree with n internal nodes is:
- In a B-tree with minimum degree t (t >= 2), every node other than the root must contain at least:
- The amortized time complexity of an operation (search, insert or delete) on a splay tree with n nodes is:
- The minimum number of states in a DFA over {0, 1} accepting exactly the strings that end with 00 is:
- Which statement about pushdown automata acceptance modes is correct?