Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pivot Partitioning by Scanning (PPbS) rearranges the elements in an array A around a given
- pivot element in place, much like the partitioning procedure used in the Quicksort algorithm,
- e.g. the one shown in the famous CLRS book.
- There are some differences though: whereas the algorithm from CLRS partitions the array into two parts
- (elements <= pivot and elements > pivot), given a pivot element which always is the last element in
- the array, PPbS partitions the array into three parts (<, ==, and > than the pivot) with a freely chosable
- pivot. PPbS, however, suffers from nested loops, so its time complexity is worse.
- PPbS returns two pointers, m1 and m2, that satisfy the following conditions:
- 1. There are m1 many elements that have a value < pivot
- 2. There are (m2 - m1) many elements that have a value == pivot
- 3. There are (n - m2) many elements that have a value > pivot, where n == A.length.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement