1 / 19

Partitioning in Quicksort

Learn how to efficiently partition an array in Quicksort by choosing the rightmost element as the partition element, scanning from the right for smaller elements, scanning from the left for larger elements, exchanging elements, and repeating until the pointers cross.

sinclairr
Download Presentation

Partitioning in Quicksort

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. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  2. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  3. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  4. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  5. Partitioning in Quicksort swap me swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  6. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  7. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  8. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  9. Partitioning in Quicksort swap me swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  10. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  11. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  12. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  13. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  14. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  15. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  16. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  17. Partitioning in Quicksort swap me • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

  18. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross swap with partitioning element pointers cross

  19. Partitioning in Quicksort • How do we partition the array efficiently? • choose partition element to be rightmost element • scan from right for smaller element • scan from left for larger element • exchange • repeat until pointers cross

More Related