Skip to content

Commit

Permalink
segment tree create , update and range query
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypotter0 committed Jan 19, 2018
1 parent 856b331 commit 91ee4fe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tree/segmenttreesum.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def next_power_of_2(n):
return n
while n & (n - 1) > 0:
n &= (n - 1)

return n << 1

if __name__ == '__main__':
Expand All @@ -62,7 +61,7 @@ def next_power_of_2(n):
print(sum_range_query(segment_tree, 2, 5, len(input)))
print(sum_range_query(segment_tree, 1, 3, len(input)))
update_value(input, segment_tree, 4, 3)
print(input)
print(segment_tree)
print(sum_range_query(segment_tree, 2, 5, len(input)))
print(sum_range_query(segment_tree, 1, 3, len(input)))


0 comments on commit 91ee4fe

Please sign in to comment.