Skip to content

Instantly share code, notes, and snippets.

@pomeo92
pomeo92 / fenwick_tree.py
Created November 30, 2016 22:25 — forked from robert-king/fenwick_tree.py
Python Binary Index Tree (Fenwick tree) with range updates.
__author__ = 'robert'
"""
Implementation inspired by Petr Mitrichev's blog post http://petr-mitrichev.blogspot.co.nz/2013/05/fenwick-tree-range-updates.html
and
Yoshiya Miyata's Quora answer http://qr.ae/pHhNN
"""
class Bit:
def __init__(self, n):