17-binary_tree - CSE143 Lecture17 BinaryTrees

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 143 Lecture 17 Binary Trees slides created by Marty Stepp and Alyssa Harding http://www.cs.washington.edu/143/
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Trees tree : A directed, acyclic structure of linked nodes. directed  : Has one-way links between nodes. acyclic  : No path wraps back around to the same node twice. binary tree  can be defined as either: empty ( null ), or root  node that contains: data left  subtree, and right  subtree. (The left and/or right subtree could be empty.) 7 6 3 2 1 5 4 root
Background image of page 2
3 Definition is recursive! The recursive definition lets us build any shape tree:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Trees in computer science folders/files on a computer family genealogy; organizational charts AI: decision trees compilers: parse tree a = (b + c) * d; d + * a = c b
Background image of page 4
5 Programming with trees Trees are a mixture of linked lists and recursion considered very elegant once understood difficult for novices to master Common student remark #1: "My code doesn't work, and I don't know why." Common student remark #2: "My code works, and I don't know why."
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Terminology root : topmost node of the tree leaf : node with no children branch : any internal node;   neither the root nor a leaf 9 21 30 78 5 29 82 16 Leaf   nodes Root node Branch nodes
Background image of page 6
7 Terminology child : Any node our node  refers to parent : the node that refers 
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/29/2010 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.

Page1 / 20

17-binary_tree - CSE143 Lecture17 BinaryTrees

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online