Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Number of nodes in a segment tree.

$
0
0

In the following implementation of segment tree, in the case when number of elements in the array for the range query, say A, are n such that n is not a power of 2, then I'm unable to establish that we actually require
2 * (pow(2,ceil((log2(n)))) - 1 nodes of the segment tree. In which case does the node variable's value in the following implementation may go past the 2*n-2 ?

https://onlinegdb.com/S1LMjFqCz (solution)

https://www.hackerearth.com/practice/data-structures/advanced-data-structures/segment-trees/practice-problems/algorithm/range-minimum-query/ (problem statement)


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>