0% found this document useful (0 votes)
39 views

Tree

This document discusses tree data structures. It defines key tree terminology like root, parent, child, leaf nodes, height, and levels. It provides examples of tree applications in file systems and compilers. Trees are classified as binary search trees, expression trees, and more. Common tree types discussed include binary search trees, balanced binary trees, and m-way search trees.

Uploaded by

Akif Vohra
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Tree

This document discusses tree data structures. It defines key tree terminology like root, parent, child, leaf nodes, height, and levels. It provides examples of tree applications in file systems and compilers. Trees are classified as binary search trees, expression trees, and more. Common tree types discussed include binary search trees, balanced binary trees, and m-way search trees.

Uploaded by

Akif Vohra
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
You are on page 1/ 8

DATA

STRUCTURES

MAHESH GOYANI
MAHATMA GANDHI INSTITUE OF TECHNICAL EDUCATION & RESEARCH CENTER
[email protected]

(C) GOYANI MAHESH 1


TREE

(C) GOYANI MAHESH 2


TERMONOLOGY

 There are a number of applications where linear data structures are not appropriate.
 Consider a tree of a Colleges.

South Gujarat University

MGITER SCET SVMIT

Computer Electronics I.T. I.C Mech PEc Civil

 A linear linked list will not be able to capture the tree-like relationship with ease.
 Shortly, we will see the applications where linear data structures are not suitable.

(C) GOYANI MAHESH 3


TERMONOLOGY

 Node An element in the tree references to data and other nodes

 Path The nodes visited as you travel from root down

 Root The node at the top It is upside down!

 Parent The node directly above another node (except root)

 Child The node(s) below a given node

 Degree The maximum number of children from one node

 Leaves/Terminal Nodes with no children/degree zero

 Height The length of a path (number of edges, -1 for empty trees)

(C) GOYANI MAHESH 4


TERMONOLOGY

 Levels The top level is 0, increases

 Forest Set of zero or more disjoint trees

 Successor Any Child of parent node

 Siblings/Brother All the Childs of same parent

 Ancestor All the nodes along the path from root to node

 Descents All the nodes along the path from node to terminal

 Size The number of descendants plus one for the node itself

(C) GOYANI MAHESH 5


APPLICATION

 File Systems (not binary)


 Hierarchical files systems include Unix and DOS
 In DOS, each \ represents an edge (In Unix, it's /)
 Each directory is a file with a list of all its children

 Binary Search Trees


 insert, remove, and find run O(log n)

 Compilers: expression tree, symbol tree

(C) GOYANI MAHESH 6


CLASSIFICATION

Trees

2-Way Binary M-Way binary


Search Search

Binary Balanced Expression Height Weight


Search Tree Binary Tree Tree Balanced Tree Balanced Tree

Height Weight
Balanced Tree Balanced Tree

(C) GOYANI MAHESH 7


Binary Tree

Strict Binary Tree

Complete Binary Tree

M-Way Search Tree

AVL Tree

Threaded Binary Tree

Algorithms

(C) GOYANI MAHESH 8

You might also like