CPSC 320 Intermediate Algorithm Design and Analysis July
- Slides: 21
CPSC 320: Intermediate Algorithm Design and Analysis July 21, 2014 1
Course Outline • • • Introduction and basic concepts Asymptotic notation Greedy algorithms Graph theory Amortized analysis Recursion Divide-and-conquer algorithms Randomized algorithms Dynamic programming algorithms NP-completeness 2
Master Theorem 3
Master Theorem • 4
In-class Exercises • 5
Problem • 6
Divide-and-Conquer Algorithms 7
Binary to Decimal conversion • 8
Binary to Decimal Analysis • 9
Faster Algorithm • Approach: divide and conquer • Divide the array in two parts, do each part separately • Divide using an appropriate power of 10 • Choose power of 10 that uses at least half of the bits 10
Faster Algorithm • 11
Faster Algorithm • 12
Exponential • 13
Divide and Conquer • 14
Time Complexity • 15
Stock trading problem • 16
Maximum Subarray • Let’s consider the daily changes (difference from previous day): • 13, -25, 20, -3, -16, -23, 18, 20, -7, 12, -5, -22, 15, -4, 7 • Now the problem becomes: finding the range with largest sum • In the example: 18, 20, -7, 12; sum is 43 • How does that help? 17
Divide and Conquer • If we divide the array in two, a maximum subarray may be in: • The first half • The second half • In between (crossing division) • We can calculate the best option for each, then select the largest • First and second half can be solved by recursion • Crossing subarray can be found in linear time • Find largest sum that ends at midpoint • Find largest sum that starts just after midpoint 18
Algorithm • 19
Algorithm • 20
Time Complexity • 21
- Cpsc 320 ubc
- Cpsc 320
- Anany levitin
- Brute force design
- Systems and forms design
- January february march april may june
- Ao * algorithm
- User interface design in system analysis and design
- Dialogue design in system analysis and design
- Two way slab load distribution
- What is intermediate code generation
- The harp harris burdick
- The mysteries of harris burdick uninvited guests
- July 1-4 1863
- Tender definition
- Diferença entre eclipse lunar e solar
- 2001 july 15
- 2003 july 17
- July 30 2009 nasa
- Sources nso july frenchhowell neill technology...
- May 1775
- I am silver and exact i have no preconceptions