Sorting1.3 - Comparison Selection Sort Bubble Sort...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Comparison Selection Sort Bubble Sort Insertion Sort Sort in place Stable sort But O(n2) running time. Can we do better? CSE 2011 Prof. J. Elder - 16 - Last Updated: 4/1/10 11:16 AM Recursive Sorts Given list of objects to be sorted Split the list into two sublists. Recursively have a friend sort the two sublists. Combine the two sorted sublists into one entirely sorted list. CSE 2011 Prof. J. Elder - 17 - Last Updated: 4/1/10 11:16 AM Merge Sort 88 52 14 31 25 98 30 23 62 79 Divide and Conquer CSE 2011 Prof. J. Elder - 18 - Last Updated: 4/1/10 11:16 AM Merge Sort Merge-sort is a sorting algorithm based on the divideand-conquer paradigm It was invented by John von Neumann, one of the pioneers of computing, in 1945 CSE 2011 Prof. J. Elder - 19 - Last Updated: 4/1/10 11:16 AM Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets S1 and S2 Recur: solve the subproblems associated with S1 and S2 Conquer: combine the solutions for S1 and S2 into a solution for S The base case for the recursion are subproblems of size 0 or 1 CSE 2011 Prof. J. Elder - 20 - Last Updated: 4/1/10 11:16 AM ...
View Full Document

Ask a homework question - tutors are online