Data Structures & AlgorithmsVery hardICPC regional · number theory
Problem: Which structure gives the best rational approximations to a real number in a tree form?
- A. A binary heap
- B. A suffix tree
- C. A Fenwick tree
- D. The Stern-Brocot tree
Correct answer: D. The Stern-Brocot tree
Each node of the Stern-Brocot tree is a fraction, and the path from the root gives continued-fraction approximations.
More Coding Interview Problems questions
- Problem: Which algorithm computes the longest path in a weighted directed acyclic graph in O(V + E)?
- Problem: What is the minimum number of colours that suffices for any planar graph?
- Problem: What is the time complexity of computing the KMP prefix function of a pattern of length m?
- Problem: Which structure supports push, pop and getting the minimum, all in O(1) amortised time?
- Problem: Which property makes counting sort stable and therefore usable inside radix sort?
- Problem: Which structure gives a queue with O(1) amortised enqueue, dequeue and minimum queries?