Advertisement
bekovski

ppbs_descr

Aug 7th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. Pivot Partitioning by Scanning (PPbS) rearranges the elements in an array A around a given
  2. pivot element in place, much like the partitioning procedure used in the Quicksort algorithm,
  3. e.g. the one shown in the famous CLRS book.
  4. There are some differences though: whereas the algorithm from CLRS partitions the array into two parts
  5. (elements <= pivot and elements > pivot), given a pivot element which always is the last element in
  6. the array, PPbS partitions the array into three parts (<, ==, and > than the pivot) with a freely chosable
  7. pivot. PPbS, however, suffers from nested loops, so its time complexity is worse.
  8.  
  9. PPbS returns two pointers, m1 and m2, that satisfy the following conditions:
  10. 1. There are m1 many elements that have a value < pivot
  11. 2. There are (m2 - m1) many elements that have a value == pivot
  12. 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