trees-102-sp10

# trees-102-sp10 - Computer Science 2 Data Structures and...

This preview shows pages 1–6. Sign up to view the full content.

Computer Science 2 Data Structures and Algorithms V22.0102 section 2 Introduction to Trees Professor: Evan Korth New York University

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

View Full Document
Road Map Introduction to trees Terminology Binary trees Tree traversal Reading: 4.1 – 4.2
Tree Tree defined recursively A tree is a collection of nodes. The collection can be empty; otherwise, a tree consists of a distinguished node r, called the root, and zero or more non-empty (sub) trees T 1 , T 2 , …, T k each of whose roots are connected by a directed edge from r. A tree is a collection of N nodes, one of which is the root and N-1 edges. Source:Mark Allen Weiss

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

View Full Document
Tree terminology The root of each subtree is said to be a child of r and r is said to be the parent of each subtree root. Leaves : nodes with no children (also known as external nodes) Internal Nodes : nodes with children Siblings : nodes with the same parent Source:Mark Allen Weiss - edited by Evan Korth
• A path from node n 1 to n k is defined as a sequence of nodes n 1 , n 2 , …, n k such that n i is the parent of n i+1 for 1<= i <= k. The length of this path is the number of edges on the path namely k-1. The length of the path from a node to itself is 0.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 18

trees-102-sp10 - Computer Science 2 Data Structures and...

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

View Full Document
Ask a homework question - tutors are online