Data Structures & AlgorithmsHardCodeforces Div2 D · data structures
Problem: Which property does an 'order statistics' tree support in addition to search?
- A. Constant-time insertion only
- B. Finding the k-th smallest element and the rank of a value in O(log n)
- C. Finding shortest paths
- D. Computing gcd
Correct answer: B. Finding the k-th smallest element and the rank of a value in O(log n)
Each node stores subtree sizes, so rank and select take O(log n) in a balanced tree.
More Coding Interview Problems questions
- Problem: What is the time complexity of the 'Mo's algorithm with updates' (time dimension added) in terms of n and q?
- Problem: Which problem asks for the length of the shortest cycle in an undirected unweighted graph?
- Problem: Which theorem guarantees a perfect matching in a bipartite graph when Hall's condition holds for the smaller side?
- Problem: What is the main idea of the 'parallel binary search' technique?
- Problem: Which structure gives fast membership tests of substrings after O(n) construction (for a fixed alphabet)?
- Problem: What is the expected number of rounds of a randomised min-cut (Karger's algorithm) needed for a graph with n vertices to find a…