Data Structures & AlgorithmsHardICPC regional · algorithm theory
Problem: What is the information-theoretic lower bound on comparisons (in the worst case) for sorting 5 distinct elements?
- A. 8
- B. 6
- C. 10
- D. 7
Correct answer: D. 7
There are 5! = 120 orders, and each comparison halves the possibilities at best, so at least ceil(log2 120) = 7 comparisons are needed.
More Coding Interview Problems questions
- Problem: Which of the following decision problems is NP-complete?
- Problem: Which statement about the subset-sum problem with target S and n items is correct in the standard sense?
- Problem: Binary lifting on a rooted tree with n nodes uses O(n log n) preprocessing. What is the time for one LCA query?
- Problem: Which statement about building a binary heap from n given elements is correct?
- Problem: Which requirement must be met before the convex hull trick can answer queries in O(1) amortised time per query with a deque?
- Problem: Johnson's algorithm reweights edges with potentials before running Dijkstra. What does the reweighting achieve?