# 10-17 notes - Computational Model of Sorting (nlogn) o...

This preview shows pages 1–2. Sign up to view the full content.

Computational Model of Sorting Θ(nlogn) o Merge sort o Heap Sort Θ(n^2) o Insertion sort o Bubble sort Comparison Sorts o All can be expressed in terms of 1. Moving elements (unconditionally) 2. A comparison operator greaterThan(A,i,j) {return (A(i) > A(j))} o How fast can we sort using ONLY moves and compare operator Idea: o Show that any sorting algorithm is either slow or wrong Approach: o Show that some min # of comparisons is needed to correctly sort all possible inputs Decision Tree Lower Bounds Claim o No comparison sort has worst-case asymptotic complexity o(nlogn) Decision Tree: a graphical depiction of an algorithm a running on inputs of size n A>b? o Yes: a>c? Yes: b>c? Yes: cba No: bca No: bac o No: b>c? Yes: a>c? Yes: cab No: acb No: abc Every comparison sort for arrays of size n has a corresponding decision tree o Internal nodes = operations o Leaves = outcomes How does this tree relate to the running time in worst case

This preview has intentionally blurred sections. Sign up to view the full version.

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

## This note was uploaded on 12/05/2011 for the course ENGINEERIN 131 taught by Professor Cytron during the Spring '11 term at Washington University in St. Louis.

### Page1 / 2

10-17 notes - Computational Model of Sorting (nlogn) o...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online