Comp 388-005 Week 5
Lewis Tower 415, 4:15-8:15
Welcome
Readings:
Sorting in Bailey and Morin
Lab 5: sorted list with access time O(log n)
Some ways to traverse a tree: traversers.cs
Alternative stack-based traverser
Queue-based traverser
Hash stats
How many buckets can we expect to use?
If hashtable array size is M and there are N things
inserted, the fill ratio is λ = N/M
Poisson distribution: fraction of buckets with k items is
λke-λ/k!
k=0: e-λ
k=1: λe-λ
Compiler
parsing: a, b, c, d, e are specific symbols, A, B, C are
higher-level constructs
A ::= a A | b B
B ::= c C { c e C }
C ::= d [ e C ]
We can parse this language with
parseA: if (token=A) {accept(a);
parseA();}
else {accept(b); parseB();}
parseB: accept(c); parseC(); while
(token==c) {accept(c); accept(e); parseC();}
parseC: accept(d); if (token==e)
{accept(e); parseC();}
machine code
recursive-descent compilation
expressions
if and while
global and local variables; stack
frames
recursion