





































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An implementation of the Quick Sort algorithm. The algorithm partitions elements based on whether they are smaller or greater than the pivot. It then finds two entries, one larger and one smaller than the pivot, which are out of order and corrects their ordering by swapping them. examples of the algorithm's implementation and sorting of sub-lists. useful for students studying algorithms and data structures.
Typology: Study notes
1 / 45
This page cannot be seen from the preview
Don't miss anything!
Next, recall that our goal is to partition all remaining elements based on whether they are smaller than or greater than the pivot We will find two entries:
Continue doing so until the appropriate entries you find are actually in order The index to the larger entry we found would be the first large entry in the list (as seen from the left) Therefore, we could move this entry into the last entry of the list We can fill this spot with the pivot 7.6.
We select 57 to be our pivot
Starting at the 2 nd and 2 nd -last locations:
We search forward until we find 97 > 57 We search backward until we find 16 < 57 7.6.
We swap 16 and 97 which are now in order with respect to each other 7.6.
We swap 63 and 55 7.6.
We search forward until we find 85 > 57 We search backward until we find 36 < 57 7.6.
We search forward until we find 68 > 57 We search backward until we find 9 < 57 7.6.
We swap 68 and 9 7.6.
We move the larger indexed item to the vacancy at the end of the array We fill the empty location with the pivot, 57 The pivot is now in the correct location 7.6.
We will now recursively call quick sort on the first half of the list When we are finished, all entries < 57 will be sorted 7.6.
We choose 24 to be our pivot We move 9 into the first location in this sub-list 7.6.
We search forward until we find 49 > 24 We search backward until we find 21 < 24 7.6.