Lecture Notes for CS 512, Algorithm Design
Algorithm Analysis, 13 March 2000
- going from algorithm to order notation - many ways
- algorithm, mathematical model (that is, function), order approximation
- knuth
- subsidiary model - computation model; ram, mix
- algorithm, order notation - structural analysis
- structural analysis - algorithm structure
- assign behavior to smaller units, then combine units following
algorithm structure to find behavior of larger units.
- statements
- usually O(1), but know your data structures - eg a[i]
vs. put_queue(q, i) vs. put_priority_queue(q, i)
- statement sequence -
s
1 ;
s
2
s
1 is O(f), s
2 is O(g), so s
1; s
2 is
O(f) + O(g)
- but what is O(f) + O(g)
- treat O(f) as a set of functions, pick a representative
function and apply the definition of big-oh.
- plus, max, constant
- example: i <- 1 ; heapify(h, i)
- loops -
do b s od
- s gets executed some number of times - asymptotically bound the
number of times
- O(f)*O(g) - what is that
- implicit, and occasionally troublesome, assumption - the loop itself
does constant work per iteration.
- if statement -
if b1 s
1 or b2 s
2 fi
- execute either
s
1 or s
2 - which one
- don't forget b1 and b2
- what about subroutine calls and recursion
- factorial
- remember - a mathematical function for resource use
- recurrence relations
- fine points
- what is the input - what's n
- making the assumptions - best, average, worst
- what's the output - what are we measuring; memory accesses,
comparisons, swaps and so on
This page last modified on 21 March 2000.