This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Binary Recursion
Binary recursion occurs whenever there are
two recursive calls for each nonbase case.
Example 1: The Fibonacci Sequence CSE 2011
Prof. J. Elder  41  Last Updated: 1/7/10 10:14 AM Trees
Chapter 7 CSE 2011
Prof. J. Elder  42  Last Updated: 1/7/10 10:14 AM Formal Definition of Rooted Tree
A rooted tree may be empty.
Otherwise, it consists of
A root node r
A set of subtrees whose roots are the children of r
r B E F I
CSE 2011
Prof. J. Elder  43  C J G D H K
Last Updated: 1/7/10 10:14 AM Tree Terminology
Root: node without parent (A)
Internal node: node with at least one child
(A, B, C, F)
External node (a.k.a. leaf ): node without
children (E, I, J, K, G, H, D)
Ancestors of a node: parent,
grandparent, grandgrandparent, etc.
Descendant of a node: child, grandchild,
grandgrandchild, etc.
Siblings: two nodes having the same
parent
Depth of a node: number of ancestors
Height of a tree: maximum depth of any
node (3)
Subtree: tree consisting of a node and its
descendants
CSE 2011
Prof. J. Elder  44  A B E C F I J G D H K Last Updated: 1/7/10 10:14 AM
subtree Position ADT
The Position ADT models the notion of place
within a data structure where a single object is
stored
It gives a unified view of diverse ways of storing
data, such as
a cell of an array
a node of a linked list
a node of a tree Just one method:
object element(): returns the element stored at the
position
CSE 2011
Prof. J. Elder  45  Last Updated: 1/7/10 10:14 AM ...
View Full
Document
 Fall '11
 Elder
 Data Structures, Recursion

Click to edit the document details