Presentation is loading. Please wait.

Presentation is loading. Please wait.

Partitioning in Quicksort n How do we partition the array efficiently? – choose partition element to be rightmost element – scan from right for smaller.

Similar presentations


Presentation on theme: "Partitioning in Quicksort n How do we partition the array efficiently? – choose partition element to be rightmost element – scan from right for smaller."— Presentation transcript:

1 Partitioning in Quicksort n 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 n 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 me

3 Partitioning in Quicksort n 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 me

4 Partitioning in Quicksort n 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 me

5 Partitioning in Quicksort n 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 me

6 Partitioning in Quicksort n 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 n 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 me

8 Partitioning in Quicksort n 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 me

9 Partitioning in Quicksort n 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 me

10 Partitioning in Quicksort n 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 n 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 n 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 n 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 n 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 me

15 Partitioning in Quicksort n 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 me

16 Partitioning in Quicksort n 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 me

17 Partitioning in Quicksort n 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 me

18 Partitioning in Quicksort n 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 pointers cross swap with partitioning element

19 Partitioning in Quicksort n 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


Download ppt "Partitioning in Quicksort n How do we partition the array efficiently? – choose partition element to be rightmost element – scan from right for smaller."

Similar presentations


Ads by Google