You could have invented Fenwick trees

1Citations
Citations of this article
2Readers
Mendeley users who have this article in their library.

Abstract

Fenwick trees, also known as binary indexed trees are a clever solution to the problem of maintaining a sequence of values while allowing both updates and range queries in sublinear time. Their implementation is concise and efficient - but also somewhat baffling, consisting largely of nonobvious bitwise operations on indices. We begin with segment trees, a much more straightforward, easy-to-verify, purely functional solution to the problem, and use equational reasoning to explain the implementation of Fenwick trees as an optimized variant, making use of a Haskell EDSL for operations on infinite two's complement binary numbers.

Cite

CITATION STYLE

APA

Yorgey, B. (2025). You could have invented Fenwick trees. Journal of Functional Programming, 35. https://doi.org/10.1017/S0956796824000169

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free