hello friends i have read segment trees from various websites , i am able to understand the approach, idea and need of segment trees can someone please explain how to implement them and code them , i need a well commented code , please help
Apart from the links @neo1tech9_7 specified, another application of segment trees is when you need to perform range queries and range update , i.e. when apart from queries, you need to perform multiple update operations on different ranges in the array. Here you will need lazy propagation. Here is a very easy to understand code.
These should help in understanding as well as implementing BIT.
- Topcoder tutorial (well commented code for all operations on BIT)
- range queries and fenwick trees (contains code & very well explained)
- intuition behind fenwick trees on stackoverflow
Problems related to BIT
answer on quora
Hope it helped
Well range queries and range update should be learnt a little later I guess as they are not really easy to get at the start
I am new to segment trees and one of the first problems i solved involved range update, & the above blog helped me a lot in that, hence i mentioned it