Presentation is loading. Please wait.

Presentation is loading. Please wait.

Quick Sort Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures.

Similar presentations


Presentation on theme: "Quick Sort Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures."— Presentation transcript:

1

2 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 “.

3 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 26537161115915481909 Scan from left to right, if the element larger than pivot key, finding a smaller item from right to left.

4 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 265371 61 115915481909 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

5 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 265371 61 115915481909 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

6 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 26537 161 115915481909 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

7 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 26537 161 115915481909 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.

8 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 26537 161 115915481909 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.

9 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 26537 161 11591548 19 09 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.

10 Quick Sort R0123456789leftright Set an array and add left and right to record the first and last indexes. Take a pivot key at first term. 26537 161 11591548 19 09 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.


Download ppt "Quick Sort Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures."

Similar presentations


Ads by Google