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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

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

{[ snackBarMessage ]}

Page1 / 2

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online