1

I know how a BIT works. But I was wondering if a BIT can be used to find the minimum/maximum element in the complete range, or more specifically, to find the minimum (or maximum) value after all the update processes have been completed. Now, I know that this can very well be achieved using Segment Trees, but is it possible to do the same using a BIT?

Thanks.

PS: I know the obvious way of traversing the complete BIT and calculating the value at each index. I am looking for a more efficient/optimized way.

Born Again
  • 2,139
  • 4
  • 25
  • 27
  • Can you elaborate on what you're trying to do? What do you mean by "after all the update processes have been completed?" – templatetypedef Nov 01 '13 at 15:29
  • @templatetypedef By "update processes" I am referring to the "update" step of a BIT. Or if it helps, just omit that part and then read the sentence. – Born Again Nov 01 '13 at 16:02
  • To confirm- you want to know the maximum or minimum value stored in a range after beginning with some initial values and incrementing/decrementing them? – templatetypedef Nov 01 '13 at 16:06
  • @templatetypedef Yes, exactly that. – Born Again Nov 01 '13 at 16:15
  • I think I'm missing something. How would iterating over a BIT help with this? – templatetypedef Nov 01 '13 at 16:46
  • @templatetypedef What I mean is, with the naive approach, I will iterate over all the elements of the BIT, and with each iteration, calculate the actual value at that index. [This link](http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=binaryIndexedTrees#reada) demonstrates what I am trying to say. – Born Again Nov 01 '13 at 17:02
  • Couldn't you do this way more directly by just making an array of counters and just incrementing and decrementing them? Why would you want to use a BIT? – templatetypedef Nov 01 '13 at 17:05
  • @templatetypedef [This is the question](http://www.codechef.com/problems/DRANGE) which I am trying to solve. You can see why I am tempted to use a BIT. It very easily does what the first part of the question wants. In the latter part, I need to tell the range, for which I need the minimum and maximum numbers. This is the motivation/reason behind this question. Hope you can throw some insights into what I am trying to do. – Born Again Nov 01 '13 at 17:14

0 Answers0