SlideShare a Scribd company logo
MBA Admission in India 
By: 
Admission.edhole.com
Tree Data Structures 
S. Sudarshan 
Based partly on material from 
Fawzi Emad & Chau-Wen Tseng 
Admission.edhole.com
Trees Data Structures 
 Tree 
 Nodes 
 Each node can have 0 or more children 
 A node can have at most one parent 
 Binary tree 
 Tree with 0–2 children per node 
Admission.edhole.com 
Tree Binary Tree
Trees 
 Terminology 
 Root  no parent 
 Leaf  no child 
 Interior  non-leaf 
 Height  distance from root to leaf 
Root node 
Interior nodes Height 
Leaf nodes 
Admission.edhole.com
Binary Search Trees 
 Key property 
 Value at node 
 Smaller values in left subtree 
 Larger values in right subtree 
 Example 
 X > Y 
 X < Z 
Y 
X 
Z 
Admission.edhole.com
Binary Search Trees 
 Examples 
Binary 
search trees 
Not a binary 
search tree 
5 
10 
30 
2 25 45 
5 
10 
45 
2 25 30 
5 
10 
30 
2 
25 
45 
Admission.edhole.com
Binary Tree Implementation 
Class Node { 
int data; // Could be int, a class, etc 
Node *left, *right; // null if empty 
void insert ( int data ) { … } 
void delete ( int data ) { … } 
Node *find ( int data ) { … } 
… 
} 
Admission.edhole.com
Iterative Search of Binary Tree 
Node *Find( Node *n, int key) { 
while (n != NULL) { 
if (n->data == key) // Found it 
return n; 
if (n->data > key) // In left subtree 
n = n->left; 
else // In right subtree 
n = n->right; 
} 
return null; 
} 
Admission.edhole.com 
Node * n = Find( root, 5);
Recursive Search of Binary Tree 
Node *Find( Node *n, int key) { 
if (n == NULL) // Not found 
return( n ); 
else if (n->data == key) // Found it 
return( n ); 
else if (n->data > key) // In left subtree 
return Find( n->left, key ); 
else // In right subtree 
return Find( n->right, key ); 
} 
Node * n = Find( root, 5); 
Admission.edhole.com
Example Binary Searches 
 Find ( root, 2 ) 
5 
10 
30 
2 25 45 
5 
10 
30 
2 
25 
45 
10 > 2, left 
5 > 2, left 
2 = 2, found 
5 > 2, left 
2 = 2, found 
root 
Admission.edhole.com
Example Binary Searches 
 Find (root, 25 ) 
5 
10 
30 
2 25 45 
5 
10 
30 
2 
25 
45 
10 < 25, right 
30 > 25, left 
25 = 25, found 
5 < 25, right 
45 > 25, left 
30 > 25, left 
10 < 25, right 
25 = 25, found 
Admission.edhole.com
Types of Binary Trees 
 Degenerate – only one child 
 Complete – always two children 
 Balanced – “mostly” two children 
 more formal definitions exist, above are intuitive ideas 
Degenerate 
binary tree 
Balanced 
binary tree 
Complete 
binary tree 
Admission.edhole.com
Binary Trees Properties 
 Degenerate 
 Height = O(n) for n 
nodes 
 Similar to linked list 
 Balanced 
 Height = O( log(n) ) 
for n nodes 
 Useful for searches 
Degenerate 
binary tree 
Balanced 
binary tree 
Admission.edhole.com
Binary Search Properties 
 Time of search 
 Proportional to height of tree 
 Balanced binary tree 
 O( log(n) ) time 
 Degenerate tree 
 O( n ) time 
 Like searching linked list / unsorted array 
Admission.edhole.com
Binary Search Tree Construction 
 How to build & maintain binary trees? 
 Insertion 
 Deletion 
 Maintain key property (invariant) 
 Smaller values in left subtree 
 Larger values in right subtree 
Admission.edhole.com
Binary Search Tree – Insertion 
 Algorithm 
1. Perform search for value X 
2. Search will end at node Y (if X not in tree) 
3. If X < Y, insert new leaf X as new left subtree for 
Y 
4. If X > Y, insert new leaf X as new right subtree 
for Y 
 Observations 
 O( log(n) ) operation for balanced tree 
Adm isInssioernti.oends hmoalye .ucnobmalance tree
Example Insertion 
 Insert ( 20 ) 
5 
10 
30 
2 25 45 
10 < 20, right 
30 > 20, left 
25 > 20, left 
Insert 20 on left 
20 Admission.edhole.com
Binary Search Tree – Deletion 
 Algorithm 
1. Perform search for value X 
2. If X is a leaf, delete X 
3. Else // must delete internal node 
a) Replace with largest value Y on left subtree 
OR smallest value Z on right subtree 
b) Delete replacement value (Y or Z) from subtree 
Observation 
 O( log(n) ) operation for balanced tree 
Adm isDseiloentio.ensd hmoalye u.cnobamlance tree
Example Deletion (Leaf) 
 Delete ( 25 ) 
5 
10 
30 
2 25 45 
10 < 25, right 
30 > 25, left 
25 = 25, delete 
5 
10 
30 
2 45 
Admission.edhole.com
Example Deletion (Internal Node) 
 Delete ( 10 ) 
5 
10 
30 
2 25 45 
5 
5 
30 
2 25 45 
2 
5 
30 
2 25 45 
Replacing 10 
with largest 
value in left 
subtree 
Replacing 5 
with largest 
value in left 
subtree 
Deleting leaf 
Admission.edhole.com
Example Deletion (Internal Node) 
 Delete ( 10 ) 
5 
10 
30 
2 25 45 
5 
25 
30 
2 25 45 
5 
25 
30 
2 45 
Replacing 10 
with smallest 
value in right 
subtree 
Deleting leaf Resulting tree 
Admission.edhole.com
Balanced Search Trees 
 Kinds of balanced binary search trees 
 height balanced vs. weight balanced 
 “Tree rotations” used to maintain balance on insert/delete 
 Non-binary search trees 
 2/3 trees 
 each internal node has 2 or 3 children 
 all leaves at same depth (height balanced) 
 B-trees 
 Generalization of 2/3 trees 
 Each internal node has between k/2 and k children 
 Each node has an array of pointers to children 
 Widely used in databases 
Admission.edhole.com
Other (Non-Search) Trees 
 Parse trees 
 Convert from textual representation to tree 
representation 
 Textual program to tree 
 Used extensively in compilers 
 Tree representation of data 
 E.g. HTML data can be represented as a tree 
 called DOM (Document Object Model) tree 
 XML 
 Like HTML, but used to represent data 
 Tree structured 
Admission.edhole.com
Parse Trees 
 Expressions, programs, etc can be 
represented by tree structures 
 E.g. Arithmetic Expression Tree 
 A-(C/5 * 2) + (D*5 % 4) 
+ 
- % 
A * * 4 
/ 2 D 5 
C 5 Admission.edhole.com
Tree Traversal 
 Goal: visit every node of a tree 
 in-order traversal 
void Node::inOrder () { 
if (left != NULL) { 
cout << “(“; left->inOrder(); cout << “)”; 
} 
cout << data << endl; 
if (right != NULL) right->inOrder() 
}Output: A – C / 5 * 2 + D * 5 % 4 
To disambiguate: print brackets 
+ 
- % 
A * * 4 
/ 2 D 5 
C 5 
Admission.edhole.com
Tree Traversal (contd.) 
 pre-order and post-order: 
void Node::preOrder () { 
cout << data << endl; 
if (left != NULL) left->preOrder (); 
if (right != NULL) right->preOrder (); 
} 
void Node::postOrder () { 
if (left != NULL) left->preOrder (); 
if (right != NULL) right->preOrder (); 
cout << data << endl; 
} 
+ 
- % 
A * * 4 
/ 2 D 5 
C 5 
Output: + - A * / C 5 2 % * D 5 4 
Output: A C 5 / 2 * - D 5 * 4 % + 
Admission.edhole.com
XML 
 Data Representation 
 E.g. 
<dependency> 
<object>sample1.o</object> 
<depends>sample1.cpp</depends> 
<depends>sample1.h</depends> 
<rule>g++ -c sample1.cpp</rule> 
</dependency> 
 Tree representation 
dependency 
object depends 
sample1.o sample1.cpp 
depends 
sample1.h 
rule 
Admission.edhole.com g++ -c …
Graph Data Structures 
 E.g: Airline networks, road networks, electrical circuits 
 Nodes and Edges 
 E.g. representation: class Node 
 Stores name 
 stores pointers to all adjacent nodes 
 i,e. edge == pointer 
 To store multiple pointers: use array or linked list 
Ahm’bad 
Delhi 
Mumbai 
Calcutta 
Admission.edhole.com Madurai 
Chennai

More Related Content

What's hot

Binary Search Tree and AVL
Binary Search Tree and AVLBinary Search Tree and AVL
Binary Search Tree and AVL
Katang Isip
 
Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
Syed Zaid Irshad
 
Bst(Binary Search Tree)
Bst(Binary Search Tree)Bst(Binary Search Tree)
Bst(Binary Search Tree)
Eleti Ganapathi
 
Binary searchtrees
Binary searchtreesBinary searchtrees
Binary searchtrees
HasnainBaloch12
 
Trees
TreesTrees
Binary search tree
Binary search treeBinary search tree
Binary search tree
Kousalya M
 
Tree
TreeTree
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
ER Punit Jain
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
Zaid Shabbir
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
Krish_ver2
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
Om Prakash
 
Binary trees1
Binary trees1Binary trees1
Binary trees1
Saurabh Mishra
 
Binary tree and Binary search tree
Binary tree and Binary search treeBinary tree and Binary search tree
Binary tree and Binary search tree
Mayeesha Samiha
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
Dwight Sabio
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structureghhgj jhgh
 
Tree data structure in java
Tree data structure in javaTree data structure in java
Tree data structure in javaIrfan CH
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary Tree
ManishPrajapati78
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Dharita Chokshi
 

What's hot (20)

Binary Search Tree and AVL
Binary Search Tree and AVLBinary Search Tree and AVL
Binary Search Tree and AVL
 
Tree traversal techniques
Tree traversal techniquesTree traversal techniques
Tree traversal techniques
 
Bst(Binary Search Tree)
Bst(Binary Search Tree)Bst(Binary Search Tree)
Bst(Binary Search Tree)
 
Binary searchtrees
Binary searchtreesBinary searchtrees
Binary searchtrees
 
Trees
TreesTrees
Trees
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Tree
TreeTree
Tree
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 
Binary trees1
Binary trees1Binary trees1
Binary trees1
 
Binary tree and Binary search tree
Binary tree and Binary search treeBinary tree and Binary search tree
Binary tree and Binary search tree
 
Binary search trees
Binary search treesBinary search trees
Binary search trees
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Tree data structure in java
Tree data structure in javaTree data structure in java
Tree data structure in java
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
 
Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary Tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 

Similar to Mca admission in india

CS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdfCS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdf
ssuser034ce1
 
CS-102 BST_27_3_14.pdf
CS-102 BST_27_3_14.pdfCS-102 BST_27_3_14.pdf
CS-102 BST_27_3_14.pdf
ssuser034ce1
 
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptxData Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
RashidFaridChishti
 
data structure on bca.
data structure on bca.data structure on bca.
data structure on bca.
invertis university
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
Anil Dutt
 
Data Structures
Data StructuresData Structures
Data Structures
Nitesh Bichwani
 
mitochondria moment and super computer integration.ppt
mitochondria moment and super computer integration.pptmitochondria moment and super computer integration.ppt
mitochondria moment and super computer integration.ppt
AMMAD45
 
bst.ppt
bst.pptbst.ppt
bst.ppt
plagcheck
 
Admissions in india 2015
Admissions in india 2015Admissions in india 2015
Admissions in india 2015
Edhole.com
 
Cinterviews Binarysearch Tree
Cinterviews Binarysearch TreeCinterviews Binarysearch Tree
Cinterviews Binarysearch Tree
cinterviews
 
Binary tree
Binary treeBinary tree
Binary tree
Maria Saleem
 
Trees - Data structures in C/Java
Trees - Data structures in C/JavaTrees - Data structures in C/Java
Trees - Data structures in C/Javageeksrik
 
BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.ppt
SARATHGARIKINA
 
BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.ppt
ItsStranger1
 
BinarySearchTrees (1).ppt
BinarySearchTrees (1).pptBinarySearchTrees (1).ppt
BinarySearchTrees (1).ppt
plagcheck
 
BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.ppt
plagcheck
 
data structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.pptdata structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.ppt
DharmannaRathod1
 
lecture-i-trees.ppt
lecture-i-trees.pptlecture-i-trees.ppt
lecture-i-trees.ppt
MouDhara1
 

Similar to Mca admission in india (20)

CS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdfCS-102 BST_27_3_14v2.pdf
CS-102 BST_27_3_14v2.pdf
 
CS-102 BST_27_3_14.pdf
CS-102 BST_27_3_14.pdfCS-102 BST_27_3_14.pdf
CS-102 BST_27_3_14.pdf
 
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptxData Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
 
data structure on bca.
data structure on bca.data structure on bca.
data structure on bca.
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
 
Data Structures
Data StructuresData Structures
Data Structures
 
mitochondria moment and super computer integration.ppt
mitochondria moment and super computer integration.pptmitochondria moment and super computer integration.ppt
mitochondria moment and super computer integration.ppt
 
bst.ppt
bst.pptbst.ppt
bst.ppt
 
Unit8 C
Unit8 CUnit8 C
Unit8 C
 
Admissions in india 2015
Admissions in india 2015Admissions in india 2015
Admissions in india 2015
 
Cinterviews Binarysearch Tree
Cinterviews Binarysearch TreeCinterviews Binarysearch Tree
Cinterviews Binarysearch Tree
 
Binary tree
Binary treeBinary tree
Binary tree
 
Trees - Data structures in C/Java
Trees - Data structures in C/JavaTrees - Data structures in C/Java
Trees - Data structures in C/Java
 
Binary trees
Binary treesBinary trees
Binary trees
 
BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.ppt
 
BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.ppt
 
BinarySearchTrees (1).ppt
BinarySearchTrees (1).pptBinarySearchTrees (1).ppt
BinarySearchTrees (1).ppt
 
BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.ppt
 
data structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.pptdata structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.ppt
 
lecture-i-trees.ppt
lecture-i-trees.pptlecture-i-trees.ppt
lecture-i-trees.ppt
 

More from Edhole.com

Ca in patna
Ca in patnaCa in patna
Ca in patna
Edhole.com
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
Edhole.com
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
Edhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
Edhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
Edhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
Edhole.com
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in india
Edhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
Edhole.com
 
Ca in patna
Ca in patnaCa in patna
Ca in patna
Edhole.com
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
Edhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
Edhole.com
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
Edhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
Edhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
Edhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
Edhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
Edhole.com
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbai
Edhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
Edhole.com
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in surat
Edhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
Edhole.com
 

More from Edhole.com (20)

Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbai
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 

Mca admission in india

  • 1. MBA Admission in India By: Admission.edhole.com
  • 2. Tree Data Structures S. Sudarshan Based partly on material from Fawzi Emad & Chau-Wen Tseng Admission.edhole.com
  • 3. Trees Data Structures  Tree  Nodes  Each node can have 0 or more children  A node can have at most one parent  Binary tree  Tree with 0–2 children per node Admission.edhole.com Tree Binary Tree
  • 4. Trees  Terminology  Root  no parent  Leaf  no child  Interior  non-leaf  Height  distance from root to leaf Root node Interior nodes Height Leaf nodes Admission.edhole.com
  • 5. Binary Search Trees  Key property  Value at node  Smaller values in left subtree  Larger values in right subtree  Example  X > Y  X < Z Y X Z Admission.edhole.com
  • 6. Binary Search Trees  Examples Binary search trees Not a binary search tree 5 10 30 2 25 45 5 10 45 2 25 30 5 10 30 2 25 45 Admission.edhole.com
  • 7. Binary Tree Implementation Class Node { int data; // Could be int, a class, etc Node *left, *right; // null if empty void insert ( int data ) { … } void delete ( int data ) { … } Node *find ( int data ) { … } … } Admission.edhole.com
  • 8. Iterative Search of Binary Tree Node *Find( Node *n, int key) { while (n != NULL) { if (n->data == key) // Found it return n; if (n->data > key) // In left subtree n = n->left; else // In right subtree n = n->right; } return null; } Admission.edhole.com Node * n = Find( root, 5);
  • 9. Recursive Search of Binary Tree Node *Find( Node *n, int key) { if (n == NULL) // Not found return( n ); else if (n->data == key) // Found it return( n ); else if (n->data > key) // In left subtree return Find( n->left, key ); else // In right subtree return Find( n->right, key ); } Node * n = Find( root, 5); Admission.edhole.com
  • 10. Example Binary Searches  Find ( root, 2 ) 5 10 30 2 25 45 5 10 30 2 25 45 10 > 2, left 5 > 2, left 2 = 2, found 5 > 2, left 2 = 2, found root Admission.edhole.com
  • 11. Example Binary Searches  Find (root, 25 ) 5 10 30 2 25 45 5 10 30 2 25 45 10 < 25, right 30 > 25, left 25 = 25, found 5 < 25, right 45 > 25, left 30 > 25, left 10 < 25, right 25 = 25, found Admission.edhole.com
  • 12. Types of Binary Trees  Degenerate – only one child  Complete – always two children  Balanced – “mostly” two children  more formal definitions exist, above are intuitive ideas Degenerate binary tree Balanced binary tree Complete binary tree Admission.edhole.com
  • 13. Binary Trees Properties  Degenerate  Height = O(n) for n nodes  Similar to linked list  Balanced  Height = O( log(n) ) for n nodes  Useful for searches Degenerate binary tree Balanced binary tree Admission.edhole.com
  • 14. Binary Search Properties  Time of search  Proportional to height of tree  Balanced binary tree  O( log(n) ) time  Degenerate tree  O( n ) time  Like searching linked list / unsorted array Admission.edhole.com
  • 15. Binary Search Tree Construction  How to build & maintain binary trees?  Insertion  Deletion  Maintain key property (invariant)  Smaller values in left subtree  Larger values in right subtree Admission.edhole.com
  • 16. Binary Search Tree – Insertion  Algorithm 1. Perform search for value X 2. Search will end at node Y (if X not in tree) 3. If X < Y, insert new leaf X as new left subtree for Y 4. If X > Y, insert new leaf X as new right subtree for Y  Observations  O( log(n) ) operation for balanced tree Adm isInssioernti.oends hmoalye .ucnobmalance tree
  • 17. Example Insertion  Insert ( 20 ) 5 10 30 2 25 45 10 < 20, right 30 > 20, left 25 > 20, left Insert 20 on left 20 Admission.edhole.com
  • 18. Binary Search Tree – Deletion  Algorithm 1. Perform search for value X 2. If X is a leaf, delete X 3. Else // must delete internal node a) Replace with largest value Y on left subtree OR smallest value Z on right subtree b) Delete replacement value (Y or Z) from subtree Observation  O( log(n) ) operation for balanced tree Adm isDseiloentio.ensd hmoalye u.cnobamlance tree
  • 19. Example Deletion (Leaf)  Delete ( 25 ) 5 10 30 2 25 45 10 < 25, right 30 > 25, left 25 = 25, delete 5 10 30 2 45 Admission.edhole.com
  • 20. Example Deletion (Internal Node)  Delete ( 10 ) 5 10 30 2 25 45 5 5 30 2 25 45 2 5 30 2 25 45 Replacing 10 with largest value in left subtree Replacing 5 with largest value in left subtree Deleting leaf Admission.edhole.com
  • 21. Example Deletion (Internal Node)  Delete ( 10 ) 5 10 30 2 25 45 5 25 30 2 25 45 5 25 30 2 45 Replacing 10 with smallest value in right subtree Deleting leaf Resulting tree Admission.edhole.com
  • 22. Balanced Search Trees  Kinds of balanced binary search trees  height balanced vs. weight balanced  “Tree rotations” used to maintain balance on insert/delete  Non-binary search trees  2/3 trees  each internal node has 2 or 3 children  all leaves at same depth (height balanced)  B-trees  Generalization of 2/3 trees  Each internal node has between k/2 and k children  Each node has an array of pointers to children  Widely used in databases Admission.edhole.com
  • 23. Other (Non-Search) Trees  Parse trees  Convert from textual representation to tree representation  Textual program to tree  Used extensively in compilers  Tree representation of data  E.g. HTML data can be represented as a tree  called DOM (Document Object Model) tree  XML  Like HTML, but used to represent data  Tree structured Admission.edhole.com
  • 24. Parse Trees  Expressions, programs, etc can be represented by tree structures  E.g. Arithmetic Expression Tree  A-(C/5 * 2) + (D*5 % 4) + - % A * * 4 / 2 D 5 C 5 Admission.edhole.com
  • 25. Tree Traversal  Goal: visit every node of a tree  in-order traversal void Node::inOrder () { if (left != NULL) { cout << “(“; left->inOrder(); cout << “)”; } cout << data << endl; if (right != NULL) right->inOrder() }Output: A – C / 5 * 2 + D * 5 % 4 To disambiguate: print brackets + - % A * * 4 / 2 D 5 C 5 Admission.edhole.com
  • 26. Tree Traversal (contd.)  pre-order and post-order: void Node::preOrder () { cout << data << endl; if (left != NULL) left->preOrder (); if (right != NULL) right->preOrder (); } void Node::postOrder () { if (left != NULL) left->preOrder (); if (right != NULL) right->preOrder (); cout << data << endl; } + - % A * * 4 / 2 D 5 C 5 Output: + - A * / C 5 2 % * D 5 4 Output: A C 5 / 2 * - D 5 * 4 % + Admission.edhole.com
  • 27. XML  Data Representation  E.g. <dependency> <object>sample1.o</object> <depends>sample1.cpp</depends> <depends>sample1.h</depends> <rule>g++ -c sample1.cpp</rule> </dependency>  Tree representation dependency object depends sample1.o sample1.cpp depends sample1.h rule Admission.edhole.com g++ -c …
  • 28. Graph Data Structures  E.g: Airline networks, road networks, electrical circuits  Nodes and Edges  E.g. representation: class Node  Stores name  stores pointers to all adjacent nodes  i,e. edge == pointer  To store multiple pointers: use array or linked list Ahm’bad Delhi Mumbai Calcutta Admission.edhole.com Madurai Chennai