Segmented Tree C Code

can anybody plz send a link on how to create a segmented tree for a given array of n numbers (C code)…?

You will find it here…still, i suggest that you implement it yourself.

Hope this helps…:slight_smile:

Very well explained here. Just try understanding how a segment tree is formed, it’ll then be easy to apply it to any problem requiring it. Also, use SEARCH options of discussion forums, you’ll get many more good links there itself!!

I developed this code when i was first understanding segment tree. It shows very basic building, updating, and query operations for both point and range for finding sum of a given range of numbers from an array. The commented parts too work well. And i think after removing unnecessary headers you can use it in C as well.

can i get the exact C code for segmented array… ??

@kunal , should i use seperate array to store sum space during tree’s construction?