Data Structures & AlgorithmsHardICPC regional · algorithm theory
Problem: Which statement about building a binary heap from n given elements is correct?
- A. It always needs O(n log n) time
- B. Floyd's bottom-up heapify builds the heap in O(n) time
- C. It needs O(n^2) time because each insert is linear
- D. It is impossible without sorting first
Correct answer: B. Floyd's bottom-up heapify builds the heap in O(n) time
Sifting down from the last internal node costs a sum that converges to O(n).
More Coding Interview Problems questions
- 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?
- Problem: Range-add updates and point queries on an array can be done with a Fenwick tree over which representation?
- Problem: What is the expected time of Rabin-Karp string matching with a good polynomial hash?
- Problem: How many pairs (i < j) of the array 1..14 have a[i] + a[j] divisible by 7? Run the code. python a = list(range(1, 15))…
- Problem: Which is the worst-case time complexity of the median-of-medians selection algorithm for finding the k-th smallest element of n…