25Binary Search Tree

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

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
Applications (general trees) Representing hierarchical information such as hierarchical file systems (directories have sub-directories), programs (parse trees); Huffman trees are used for (de-)compressing information (files); An efficient data structure to implement abstract data types such as heaps, priority queues and sets.
Background image of page 3

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

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

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

View Full DocumentRight Arrow Icon
Binary tree Binary trees can be defined recursively, A binary tree is empty, or; A binary tree consists of a value as well as two sub-trees;
Background image of page 6
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.
Background image of page 7

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

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

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