Data Structures & AlgorithmsModerateTCS NQT · sorting
Problem: What is the worst-case complexity of Heapsort on n elements?
- A. O(n^2)
- B. O(n)
- C. O(log n)
- D. O(n log n)
Correct answer: D. O(n log n)
Each of the n extract-max steps costs O(log n), and heap construction is O(n).
More Coding Interview Problems questions
- Problem: What is the property of a 'Monge' matrix that enables fast DP optimisation?
- Problem: Which problem is classically solved by the 'convex hull trick' in DP with linear functions?
- Problem: What is the cost of inserting into a binary search tree that is perfectly balanced with n nodes?
- Problem: Which concept explains why the smallest enclosing circle is determined by at most three boundary points?
- Problem: Which statement about the Hungarian algorithm's time complexity is correct for an n x n assignment problem?
- Problem: What is the purpose of the 'Floyd cycle detection' algorithm?