03/12/13 Trees and CFGs Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1
Last class: recursive functions 2
Today’s lecture: Trees and CFGs Trees – Examples of uses – Terminology – Induction on trees Context free grammars (CFGs) – What they are, how they work – Induction on CFG 3
Tree: special form of graph with “root” and no cycles 4 root
Tree terminology Nodes: root, internal, leaf, level, tree height Relations: parent/child/sibling, ancestor/descendant 5 overhead
Another example root
Another example root
Trees for sorting 8 > < > <
Decision trees 9
Hierarchical data structure 10
Trees for clustering 11 b>5 x x x x x x x x x x x 1 23 a b 5 6 a>6 1 yes no yes 2 3
More terminology 12 overhead
Induction proof on trees 13 overhead
Context-free Grammars 14 overhead
CFG Example 15 overhead
Examples of parse trees 16 Language Fig: Johnson 2007
Examples of parse trees 17 Figs: Zhu and Mumford 2007 Scene parse Object Parse
Examples of parse trees 18 Stochastic CFG for blackjack actions
Induction proof on CFG 19 overhead
CFG example 20 * I like to eat apples and bananas overhead
Things to remember Trees are a special graph with root and no cycles, with many uses – Sorting, clustering, finding similar values – Decision tree: machine learning, modeling choices – Parse trees: representing hierarchical structures Context free grammars: generate parse trees Proofs on trees: split at root, use inductive hypothesis on subtrees headed by the root’s children 21
Next class: more trees Recursion trees and more proofs with trees 22