摘要: function partition(array, left, right, pivotIndex) pivotValue := array[pivotIndex] swap array[pivotIndex] and array[right] // Move pivot to end storeIndex := left for i from left to right - 1 // left ≤ i < right if array[i] < pivotValue swap array[i] and array[... 阅读全文
posted @ 2011-06-02 14:49 反正我信了 阅读(179) 评论(0) 推荐(0)
摘要: function partition(list, left, right, pivotIndex) pivotValue := list[pivotIndex] swap list[pivotIndex] and list[right] // Move pivot to end storeIndex := left for i from left to right if list[i] < pivotValue swap list[storeIndex] and list[i] increment... 阅读全文
posted @ 2011-06-02 14:45 反正我信了 阅读(594) 评论(0) 推荐(0)
摘要: function quickfindFirstK(list, left, right, k) if right > left select pivotIndex between left and right pivotNewIndex := partition(list, left, right, pivotIndex) if pivotNewIndex > k // new condition quickfindFirstK(list, left, pivotNewIndex-1, k) if pivotNewIndex < k quickfindFirstK(list, 阅读全文
posted @ 2011-06-02 14:12 反正我信了 阅读(216) 评论(0) 推荐(0)