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

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

View Full Document Right Arrow Icon
Computer Science 2 Data Structures and Algorithms V22.0102 section 2 Introduction to Trees Professor: Evan Korth New York University
Background image of page 1

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

View Full DocumentRight Arrow Icon
Road Map Introduction to trees Terminology Binary trees Tree traversal Reading: 4.1 – 4.2
Background image of page 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
• 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.
Background image of page 5

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

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

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 Right Arrow Icon
Ask a homework question - tutors are online