1 / 30

3-Way Partitioning

3-Way Partitioning. 3-way partitioning. Choose partitioning element. Scan from left  element. Scan from right for  element. Exchange. Move to left or right end if equal. Repeat until pointers cross. A. B. X. W. P. P. V. P. D. P. C. Y. Z. P. p. q. partition element.

coral
Download Presentation

3-Way Partitioning

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B X W P P V P D P C Y Z P p q partition element unpartitioned partitioned

  2. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B X W P P V P D P C Y Z P p q

  3. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B X W P P V P D P C Y Z P p q

  4. swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B X W P P V P D P C Y Z P p q

  5. swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B X W P P V P D P C Y Z P p q

  6. swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B X W P P V P D P C Y Z P p q

  7. swap me swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B X W P P V P D P C Y Z P p q

  8. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B C W P P V P D P X Y Z P p q

  9. swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B C W P P V P D P X Y Z P p q

  10. swap me swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B C W P P V P D P X Y Z P p q

  11. swap left 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. A B C P P P V P D W X Y Z P p q

  12. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A P P V P D W X Y Z P p q

  13. swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A P P V P D W X Y Z P p q

  14. swap me swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A P P V P D W X Y Z P p q

  15. swap right 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A D P V P P W X Y Z P p q

  16. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A D P V P Z W X Y P P p q

  17. swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A D P V P Z W X Y P P p q

  18. swap me swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A D P V P Z W X Y P P p q

  19. swap left 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P B C A D P V P Z W X Y P P p q

  20. swap right 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P P C A D B V P Z W X Y P P p q

  21. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P P C A D B V Y Z W X P P P p q

  22. swap me 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P P C A D B V Y Z W X P P P p q

  23. 3-Way Partitioning • 3-way partitioning. • Choose partitioning element. • Scan from left  element. • Scan from right for  element. • Exchange. • Move to left or right end if equal. • Repeat until pointers cross. P P C A D B V Y Z W X P P P p q pointers cross

  24. swap me swap me 3-Way Partitioning • 3-way partitioning. • Swap elements on left with elements in middle. • Swap elements on right with elements in middle. P P C A D B V Y Z W X P P P p q

  25. swap me swap me 3-Way Partitioning • 3-way partitioning. • Swap elements on left with elements in middle. • Swap elements on right with elements in middle. B P C A D P V Y Z W X P P P p q

  26. 3-Way Partitioning • 3-way partitioning. • Swap elements on left with elements in middle. • Swap elements on right with elements in middle. B D C A P P V Y Z W X P P P p q

  27. swap me swap me 3-Way Partitioning • 3-way partitioning. • Swap elements on left with elements in middle. • Swap elements on right with elements in middle. B D C A P P V Y Z W X P P P p q

  28. swap me swap me 3-Way Partitioning • 3-way partitioning. • Swap elements on left with elements in middle. • Swap elements on right with elements in middle. B D C A P P P Y Z W X P P V p q

  29. swap me swap me 3-Way Partitioning • 3-way partitioning. • Swap elements on left with elements in middle. • Swap elements on right with elements in middle. B D C A P P P P Z W X P Y V p q

  30. 3-Way Partitioning • 3-way partitioning. • Swap elements on left with elements in middle. • Swap elements on right with elements in middle. B D C A P P P P P W X Z Y V p q 3-way partitioned!

More Related