1 / 11

03/14/13

More Trees. 03/14/13. M agritte. Discrete Structures (CS 173) Derek Hoiem, University of Illinois. Last class: trees and CFGs. Trees are a special graph with root and no cycles, with many uses Sorting, clustering, finding similar values Decision tree: machine learning, modeling choices

fox
Download Presentation

03/14/13

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. More Trees 03/14/13 Magritte Discrete Structures (CS 173) Derek Hoiem, University of Illinois

  2. Last class: trees and CFGs • 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

  3. Tree terminology Nodes: root, internal, leaf, level, tree height Relations: parent/child/sibling, ancestor/descendant root level = 0 parent, child level = 1 internal subtree level = 2 level = 3 leaves

  4. This lecture: more trees • Recursion trees for illustrating computation in recursive functions • Another tree proof

  5. Useful formulas

  6. Recursion trees cost of input cost of subproblem split in 2 How many levels before base case? Sum of values in each level? How many leaf nodes? Total cost = sum of leaf costs + sum of internal costs:

  7. Recursion trees

  8. Recursion trees A A

  9. Tree induction proof If is a binary tree with root , then its rank is (a) if has no children (b) if has two children, both with rank (c) otherwise, the maximum rank of any of the children

  10. Tree induction proof If is a binary tree with root , then its rank is (a) if has no children (b) if has two children, both with rank (c) otherwise, the maximum rank of any of the children Claim: A tree with rank has at least leaves.

  11. Have a great break!

More Related