Data Structures19 sections · 729 units
Open in Course

Section Recap

What you learned

Segment trees: O(logn)O(\log n) range queries with updates. Structure: Array-based binary tree.

Node ii has children 2i2i and 2i+12i+1. Core Operations:

  • Build from array: O(n)O(n)
  • Point update: O(logn)O(\log n)
  • Range query: O(logn)O(\log n)

Lazy Propagation: For range updates.

Mark nodes as "lazy" and push updates when needed. Common Uses: Range sum, min, max, GCD, count. Time: O(logn)O(\log n). Space: O(n)O(n).