03 Asymptotics and Recurrences

03 Asymptotics and Recurrences - Analyzing Algorithms:...

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

View Full Document Right Arrow Icon
Analyzing Algorithms: Asymptotic Analysis and Recurrences 15-211: Fundamental Data Structures and Algorithms Charlie Garrod 19 January 2010 Reading for today: Chapter 5 and 8.5
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Announcements HW 0 theory questions due now Programming due tonight by 11:59 PM HW 1 should be out today Abstract Syntax Trees JUnit in recitation tomorrow Bring your laptops! Academic Development peer tutoring Mudge Library, Tuesdays and Thursdays from 8:30 - 11 p.m.
Background image of page 2
3 Last time…The Union-Find Problem Two operations for disjoint sets: Find(x) : Given item x find the set containing x Union(x,y) : Merge sets containing x and y Two tricks for good performance: Union-by-rank: Link smaller tree to other root Path compression: Redirect links to the root Amortized analysis O( m log n ) with Union-by- rank O( m* (m,n) ) with both Union-by-rank and path compression
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Today: Analyzing algorithms Asymptotic analysis How is analyzing algorithms like Ghostbusters ? Recurrence relations Substitution method Iteration method Master method
Background image of page 4
5 Quantifying time complexity Suppose I want to find if an array A contains a certain item k : Consider: containsItem([4,2,6,3,9], 10) containsItem([11,2,25,2,8,7,3,1,9,33], 10) containsItem([10,24,5,9,1,78,23,31,99], 10) public boolean containsItem(int[] A, int k) { int n = A.length; for (int i = 0; i < n; i++) if (A[i] == k) return true; return false; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Quantifying time complexity containsItem([a 0 , a 1 , …, a n-1 ], k) Worst-case for a particular problem size Counting steps, not wall-clock time Denoted T(n) , for inputs of size n public boolean containsItem(int[] A, int k) { int n = A.length; for (int i = 0; i < n; i++) if (A[i] == k) return true; return false; }
Background image of page 6
7 Selecting the best algorithm, part 1 Graph image source: wikipedia T 1 (n) = n 3 -1 2n 2 + 20n + 110 T 2 (n) = n 3 + n 2 + 5n + 5 Input size ( n ) T(n)
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 For larger inputs… Graph image source: wikipedia T 1 (n) = n 3 -1 2n 2 + 20n + 110 T 2 (n) = n 3 + n 2 + 5n + 5 Input size ( n ) T(n)
Background image of page 8
9 For even larger inputs… Graph image source: wikipedia T 1 (n) = n 3 -1 2n 2 + 20n + 110 T 2 (n) = n 3 + n 2 + 5n + 5 Input size ( n ) T(n)
Background image of page 9

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

View Full DocumentRight Arrow Icon
10 Selecting the best algorithm, part 2
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 05/10/2011.

Page1 / 50

03 Asymptotics and Recurrences - Analyzing Algorithms:...

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

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