25Binary Search Tree

# 25Binary Search Tree - ITI 1121 Introduction to Computing...

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

ITI 1121. Introduction to Computing II * Marcel Turcotte School of Information Technology and Engineering Version of March 26, 2011 Abstract Binary search tree (part I) * These lecture notes are meant to be looked at on a computer screen. Do not print them unless it is necessary.

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

View Full Document
Binary tree A binary tree is a tree-like (hierarchical) data structure such that each node stores a value and has at most two children, which are called left and right . 5 8 15 9 29 11
Applications (general trees) Representing hierarchical information such as hierarchical ﬁle systems (directories have sub-directories), programs (parse trees); Huﬀman trees are used for (de-)compressing information (ﬁles); An eﬃcient data structure to implement abstract data types such as heaps, priority queues and sets.

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

View Full Document
5 8 15 9 29 11 All the nodes except one have exactly one parent. That node that has no parent is called the root (which is drawn at the top of the diagram). Each node has 0, 1 or 2 children. Nodes that have no children are called leaves (or external nodes). Links between nodes are called branches .
Binary tree 5 8 15 9 29 11 A node and its descendants is called a subtree . The size of tree is the number of nodes in the tree. An empty tree has size 0. Since the discussion is restricted to binary trees, we will sometimes use the word tree to mean a binary tree.

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

View Full Document
Binary tree Binary trees can be deﬁned recursively, A binary tree is empty, or; A binary tree consists of a value as well as two sub-trees;
Binary tree The depth of a node is the number of links starting from the root that must be followed to reach that node. The root is the most accessible node.

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.

## This note was uploaded on 03/02/2012 for the course ITI 1121 taught by Professor Samaan during the Winter '10 term at University of Ottawa.

### Page1 / 26

25Binary Search Tree - ITI 1121 Introduction to Computing...

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

View Full Document
Ask a homework question - tutors are online