- Pre A An Array Of Numbers Initially Low 0 High Size Of A 1 Post Returns The Position Of The Pivot And A Is Par 1 (50.51 KiB) Viewed 55 times
// PRE A an array of numbers initially low = 0 high = size of A 1 // POST Returns the position of the pivot and A is par
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
// PRE A an array of numbers initially low = 0 high = size of A 1 // POST Returns the position of the pivot and A is par
// PRE A an array of numbers initially low = 0 high = size of A 1 // POST Returns the position of the pivot and A is partitioned with // elements to the left of the pivot being <= pivot and elements to the right of the pivot being >=pivot // int partition (A low high) pivot = A high] i = low-1 for j from low to (high-1) do if pivot > Aj] then do i=i+1 swap Alj] with Ali] swap Ali+1] with the pivot element at Alhigh] return (i+1) 1. (30 POINTS) Prove correctenss of partition. 2. (10 POINTS) Use partition to write a version of Quicksort that sorts a numerical array A in place.