Partitioning in Quicksort - PowerPoint PPT Presentation

amina
partitioning in quicksort n.
Skip this Video
Loading SlideShow in 5 Seconds..
Partitioning in Quicksort PowerPoint Presentation
Download Presentation
Partitioning in Quicksort

play fullscreen
1 / 19
Download Presentation
Presentation Description
73 Views
Download Presentation

Partitioning in Quicksort

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Q U I C K S O R T I S C O O L partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross.

  2. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. Q U I C K S O R T I S C O O L

  3. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. Q U I C K S O R T I S C O O L

  4. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. Q U I C K S O R T I S C O O L

  5. swap me swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. Q U I C K S O R T I S C O O L


  6. partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C U I C K S O R T I S Q O O L

  7. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C U I C K S O R T I S Q O O L

  8. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C U I C K S O R T I S Q O O L

  9. swap me swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C U I C K S O R T I S Q O O L

  10. partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  11. partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  12. partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  13. partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  14. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  15. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  16. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  17. swap me partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. C I I C K S O R T U S Q O O L

  18. partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. swap with partitioning element pointers cross C I I C K S O R T U S Q O O L

  19. partition element unpartitioned left partitioned right Partitioning in Quicksort • How do we partition in-place efficiently? • Partition element = rightmost element. • Scan from left for larger element. • Scan from right for smaller element. • Exchange. • Repeat until pointers cross. partition is complete C I I C K L O R T U S Q O O S