1 / 9

Quick Sort

Quick Sort. Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures in C “. Quick Sort. Set an array and add left and right to record the first and last indexes. Take a pivot key at first term.

dloftis
Download Presentation

Quick Sort

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. Quick Sort Instructor : Prof. Jyh-Shing Roger Jang Designer:Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures in C “ .

  2. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. 26 5 37 1 61 11 59 15 48 19 0 9

  3. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. If j <= i (j : right to left; i : left to right), change the j and pivot key. Take the left and right array of pivot key to do the same way 26 5 19 1 15 11 59 48 37 0 9 61

  4. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. If j <= i (j : right to left; i : left to right), change the j and pivot key. Take the left and right array of pivot key to do the same way 11 5 19 1 15 26 59 48 37 0 9 61

  5. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. If j <= i (j : right to left; i : left to right), change the j and pivot key. Take the left and right array of pivot key to do the same way 11 5 19 15 26 59 48 37 0 9 1 61

  6. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. If j < i (j : right to left; i : left to right), change the j and pivot key. Take the left and right array of pivot key to do the same way If j = pivot key, don’t change. 5 11 19 15 26 59 48 37 0 9 1 61

  7. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. If j <= i (j : right to left; i : left to right), change the j and pivot key. Take the left and right array of pivot key to do the same way If j = pivot key, don’t change. 5 11 19 15 26 59 48 37 0 9 1 61

  8. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. If j <= i (j : right to left; i : left to right), change the j and pivot key. Take the left and right array of pivot key to do the same way If j = pivot key, don’t change. 5 11 15 26 59 48 37 0 9 1 19 61

  9. Quick Sort Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left. If j <= i (j : right to left; i : left to right), change the j and pivot key. Take the left and right array of pivot key to do the same way If j = pivot key, don’t change. 5 11 15 26 48 37 59 0 9 1 19 61

More Related