analysis - recur by using the pivot in Select algorithm -


I have a problem and I can not get the purpose of lines for this site (14,15,16,17) Select algorithms.

The site on which this question was located was located.

Edited: Also, is it true that these rows "Write and re-use the compose pivot" ? ("M" is my axis and "i" is the input of this algorithm)

  arrOne & lt; - {arr: a & lt; M} arrTwo & lt; - arr A: A & gt; M} Select (i & lt; m) again (arrOne, i) and if (i> m) then select Return (arr2, im) and back to  

This is where the partition chooses to recurs the partition.

For example, then looking for the middle of an array with 100 elements. The first time you divide, you are called a division of 60 and 40 items. Since you are searching 50 th items, you know should in the left partition (which has 60 items).

Then you divide, and get, we will say, the left and right divisions of 25 and 35 items respectively. This time we can see that 50 th items should be in correct division, so we recurse in that one.

Until we continue to do this, we have a division in which only one item - which we are looking for.


Comments