Data Structures & AlgorithmsHardProduct Company SDE · segment tree
Problem: What does 'lazy propagation' in a segment tree guarantee for a range-add update?
- A. Every leaf is updated immediately
- B. Only O(log n) nodes are touched, and pending tags are pushed down on demand
- C. Updates cost O(n) each
- D. The tree is rebuilt after each update
Correct answer: B. Only O(log n) nodes are touched, and pending tags are pushed down on demand
Tags are stored at canonical nodes and pushed down only when a child is accessed.
More Coding Interview Problems questions
- Problem: Which result is the basis of Mo's algorithm's complexity analysis?
- Problem: What is the expected number of comparisons of randomised quicksort on n distinct elements?
- Problem: Which property does the 'exchange argument' prove for an optimal greedy algorithm?
- Problem: Which structure supports both insertion and 'k-th smallest' queries in O(log n) each?
- Problem: What is the complexity of the Edmonds-Karp algorithm in terms of V and E?
- Problem: Which theorem counts the spanning trees of a graph as a determinant of a reduced Laplacian matrix?