Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 101 – Oct. 21 Sorting Much-studied problem in CS – many ways to do it Given a list of data, need to arrange it “in order” Some methods do better based.

Similar presentations


Presentation on theme: "CS 101 – Oct. 21 Sorting Much-studied problem in CS – many ways to do it Given a list of data, need to arrange it “in order” Some methods do better based."— Presentation transcript:

1 CS 101 – Oct. 21 Sorting Much-studied problem in CS – many ways to do it Given a list of data, need to arrange it “in order” Some methods do better based on type of data or how distributed

2 Some Methods Selection sort: Find the largest value and swap it into first, find 2nd largest value and put it 2nd, etc. Bubble sort: Scan the list and see which consecutive values are out of order and swap them Insertion sort: Place the next element in the correct place by shifting other ones over to make room Merge sort: Split list in half until just 1-2 elements. Merge adjacent lists by collating them

3 Check out Website demo of many sorting methods
Doing operations in parallel can speed up sorting Ex. In bubble sort, we can swap #1 and #2 at the same time as #3 and #4, etc.


Download ppt "CS 101 – Oct. 21 Sorting Much-studied problem in CS – many ways to do it Given a list of data, need to arrange it “in order” Some methods do better based."

Similar presentations


Ads by Google