Skip to main content

Fenwick Tree / BIT

Learn Fenwick Tree / BIT (Advanced Data Structures, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

A Simpler O(log n) Structure for Prefix Sums A Fenwick Tree (Binary Indexed Tree) supports point updates and PREFIX sum queries in O(log n), using a single array and clever bit manipulation - no explicit tree nodes or pointers needed, and far less code than a Segment Tree. The trick: index i 's value covers a range determined by i 's LOWEST SET BIT.

More lessons in Advanced Data Structures