Midterm Review1.9

Midterm Review1.9 - Binary Recursion Binary recursion...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Binary Recursion Binary recursion occurs whenever there are two recursive calls for each non-base 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, grand-grandparent, etc. Descendant of a node: child, grandchild, grand-grandchild, 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

Page1 / 5

Midterm Review1.9 - Binary Recursion Binary recursion...

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

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