Skip to content

Data Structures -> PBDS / Order Statistics Tree

GNU PBDS ordered tree for online rank, k-th, and count-smaller queries, with a pair-key wrapper when duplicates matter.

  • Topic slug: data-structures/pbds-order-statistics
  • Tutorial page: Open tutorial
  • Ladder page: Open ladder
  • Repo problems currently tagged here: 1
  • Repo companion pages: 5
  • Curated external problems: 3

Microtopics

  • order-of-key
  • find-by-order
  • dynamic-rank
  • kth-smallest
  • pair-key-wrapper
  • gnu-pbds

Learning Sources

Source Type
GCC tree_order_statistics_node_update Primary
GCC PBDS manual Primary
Competitive Programmer's Handbook Reference

Practice Sources

Source Type
SPOJ ORDERSET Practice
CSES Josephus Problem II Practice
CSES Salary Queries Practice

Repo Companion Material

Material Type
Order Statistics Tree hot sheet quick reference
PBDS starter route starter route
ORDERSET note anchor note
Heaps And Ordered Sets tutorial compare point
Fenwick Tree tutorial compare point

Curated External Problems

Core

Problem Source Difficulty Context Style Prerequisites Tags Why it fits
ORDERSET - Order Statistic Set SPOJ Medium Order Statistics Data-Structure-Heavy; Classic Ordered Set Invariant; Order Of Key; Find By Order Kth-Smallest; Rank-Query The cleanest first benchmark where the whole problem is insert, delete, k-th, and count-smaller on one dynamic ordered set.

Practice

Problem Source Difficulty Context Style Prerequisites Tags Why it fits
Josephus Problem II CSES Hard Circular Elimination Simulation-Heavy; Data-Structure-Heavy Find By Order; Alive Set Maintenance; Modulo Indexing Find-By-Order; Josephus A clean follow-up where the alive set stays explicit and find_by_order drives repeated circular removals.

Bridge

Problem Source Difficulty Context Style Prerequisites Tags Why it fits
Salary Queries CSES Medium Order Statistics Query-Heavy; Data-Structure-Heavy Pair-Key Wrapper; Order Of Key; Count In Range Duplicate-Safe-Wrapper; Range-Count A very teachable bridge from unique sets to duplicate-safe pair-key wrappers for count-in-range queries under updates.

Repo Problems

Code Title Fit Difficulty Pattern Note Solution
ORDERSET Order Statistic Set primary medium - Note Code

Regeneration

python3 scripts/generate_problem_catalog.py