Selection algorithm: Difference between revisions

Content deleted Content added
Babobibo (talk | contribs)
Developing recursion in the cost bound doesn't provide a real proof per se.
(correct changes from Revision as of 03:02, 18 April 2011
Line 51:
pivotIndex := ... ''// select a pivotIndex between left and right''
pivotNewIndex := partition(list, left, right, pivotIndex)
pivotDist := pivotNewIndex - left + 1
''// The pivot is in its final sorted position,''
''// so pivotDist reflects its 1-based position if list were sorted''
Line 67:
pivotIndex := ... ''// select pivotIndex between left and right''
pivotNewIndex := partition(list, left, right, pivotIndex)
pivotDist := pivotNewIndex - left + 1
'''if''' pivotDist = k
'''return''' list[pivotNewIndex]