SlideShare a Scribd company logo
PRESENTATION ON
Tree
in
Data Structure
1
DATA STRUCTURE
Store and organize data in computer.
Linear Data Structure
Arrays
Linked List
Stacks
Queues 2
LOGIC OF TREE
Used to represent hierarchica data.
Shuvo(CEO)
Shawon(CTO ) Tarun(Presedent)
Bithi Moni Sila Rashel Raj
Dola Shakila Riaj Shakib 3
Used to represent hierarchical data.
Shuvo(CEO)
Shawon(CTO ) Tarun(Presedent)
Bithi Moni Sila Rashel Raj
Dola Shakila Riaj Shakib 4
 A Collection of entities called Nodes.
 Tree is a Non-Linear Data Structure.
 It’s a hierarchica Structure.
TREE
Nodes
5
Root-The top most Node.
Children
Parents
Siblings- Have same parents.
Leaf- Has no Child.
RELATION OF TREE
1
3
2
4
6
5
8
7
11109
6
EDGES, DEPTH, HEIGHT
 Edges: If a tree have N nodes
It have N-1 edges.
 Depth of x: Length of path from
Root to x.
 Hight of x: No. Of edges in longest
Path from x to a leaf
Nodes
Leaf7
SOME APPLICATION OF TREE IN COMPUTER SCIENCE
1. Storing naturally hierarchicl data- File system.
2. Organige data for quick search, insertion, deletion- Binary search
tree.
3. Dictionary
4. Network Routing Algorithm.
8
Each node can have at most 2 childern.
A node have only left and right child or
Only left child or
Only right child.
A leaf node has no left or right child.
A leaf node has only NULL.
BINARY TREE
Root
Right- child
of root.
Left-child
of root
Leaf
NULL9
STRICT/PROPER BINARY TREE
Each node can have either
2 or 0 child
Root
10
COMPLETE BINARY TREE
 The last level is completely filled.
 All nodes are as left as possible.
Root
L-2
L-3
L-4
L-1
11
PARFECT BINARY TREE
All the levels are comletely filled.
Root
L-2
L-3
L-1
12
WE CAN IMPLEMENT BINARY TREE USING
A) Dynamically created nodes.
struct node
{
int data;
struct node* left;
struct node* right
}
2
4 6
13
OR
0 1 2 3 4 5 6
B) Arrays: It only works “complete Binary tree”.
For node at index i;
Left-child-index=2i+1
Right-child-index=2i+2
2 4 1 5 8 7 9
14
IMPLEMENT OF BINARY SEARCH TREE
Value of all the nodes in left subtree is Lesser or Equal.
Value of all the nodes in right subtree is greater.
Left-Subtree Right-Subtree
(Lesser) (Greater)
15
EXAMPLE
 15>10-Left
 15<20-Right
 10>8-Left
 10<12-Right
 20>17-Left
 20<25-Right
15
2010
12 258 17
Root
16
BINARY TREE TRAVERSAL
Tree traversal
Breadth-first or
Lever-order
F,D,J,B,E,G,K,A,C,I,H
Depth-first
Preorder, Inorder &
Postorder
F
JD
I
E KB G
A C
Root
H
17
PREORDER(DLR)
Data Left Right
<root><left><right>
F,D,B,A,C,E,J,G,I,H,K
Void Postorder(struct bstnode* root)
{
if(root==NULL)
Postorder(root->right);
Postordrt(root->right);
printf(“%c”,root->data);
}
F
JD
I
E KB G
A C
Root
H
18
INORDER(LDR)
Left Data Right
<left><root><right>
A,B,C,D,E,F,G,H,I,J,K
Void Inorder(struct bstnode* root)
{
if(root==NULL) return;
Inorder(root->left);
printf(“%c”,root->data);
Inorder(root->right);
}
F
JD
I
E KB G
A C
Root
H
19
POSTORDER(LRD)
Left Right Data
<left><right><root>
A,C,B,E,D,H,I,G,K,J,F,A,B
Void Postorder(struct bstnode* root)
{
if(root==NULL)
Postorder(root->right);
Postordrt(root->right);
printf(“%c”,root->data);
}
F
JD
I
E KB G
A C
Root
H
20
SEARCH AN ELEMENT IN BST
bool Search( bstnode* root, data type)
{
if (root==NULL) return false;
else if(root->data == data) return true;
else if(root->data <= data)
return Search(root->left, data);
else
return Search(root->right, data);
}
12
155
14
7 173 13
8 11
Root
21
DLELETE A NODE FROM BST
 There are three items to delete.
 Case 1: No Child
 Case 2: One Child
 Case 3: Two Child
12
155
14
7 173 13
8 11
Root
22
CASE 1: NO CHILD
 Remove to reference of the Node
 From it’s parent &
 Return NULL
12
155
14
7 173 13
8 11
Root
23
CASE 2: ONE CHILD
 Find the Node to Delete
 Link it’s parent to this only child.
 Remain attached to the tree.
12
155
14
7 173 13
8 11
Root
24
CASE 3: TWO CHILD
Two way to delete.
1.
Find minimum in right
Copy the value in targetted node
Delete duplicate from right subtree.
12
155
14
7 173 13
8 11
Root
25
CASE 3: TWO CHILD
2.
Find maximum in left
Copy the value in targetted node
Delete duplicate from left-subtree.
12
155
14
7 173 13
8 11
Root
26
RUNNING TIME OF OPERATION
Operation Array Link List Binary Search
Tree(average case)
Search(x)-Search
for an element x.
O(Log n) O(n) O(Log n)
Insertion(x)-Insert
an element x.
O(n) O(1) O(Log n)
Remove(x)-
Remove an
element x.
O(n) O(n) O(Log n)
27
28

More Related Content

What's hot

Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
Adam Mukharil Bachtiar
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
Linked list
Linked listLinked list
Linked list
Trupti Agrawal
 
Linked list
Linked listLinked list
Linked list
KalaivaniKS1
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Albin562191
 
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
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
Kamran Zafar
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
Trupti Agrawal
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
khabbab_h
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
Red black trees
Red black treesRed black trees
Red black trees
mumairsadiq
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
Madhu Bala
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
Tirthika Bandi
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
Anand Ingle
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
chauhankapil
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
Abhishek L.R
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
Krish_ver2
 

What's hot (20)

Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Red black trees
Red black treesRed black trees
Red black trees
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 

Viewers also liked

Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
Zaid Shabbir
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
Äshïsh Jäïn
 
Tree
TreeTree
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
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
Ashim Lamichhane
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
GowriKumar Chandramouli
 
Tree
TreeTree
Binary tree
Binary  treeBinary  tree
Binary tree
Vanitha Chandru
 
Lecture7 data structure(tree)
Lecture7 data structure(tree)Lecture7 data structure(tree)
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 
Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)Arvind Devaraj
 
Linked list
Linked listLinked list
Linked list
akshat360
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsAakash deep Singhal
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
anooppjoseph
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
Waheed Khalid
 
B Trees
B TreesB Trees

Viewers also liked (20)

Trees data structure
Trees data structureTrees data structure
Trees data structure
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Tree
TreeTree
Tree
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Tree
TreeTree
Tree
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Lecture7 data structure(tree)
Lecture7 data structure(tree)Lecture7 data structure(tree)
Lecture7 data structure(tree)
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Binary tree
Binary treeBinary tree
Binary tree
 
Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)
 
Linked list
Linked listLinked list
Linked list
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
 
B Trees
B TreesB Trees
B Trees
 

Similar to Tree in data structure

Data structure tree - beginner
Data structure tree - beginnerData structure tree - beginner
Data structure tree - beginner
MD. MARUFUZZAMAN .
 
Data structure tree - intermediate
Data structure tree - intermediateData structure tree - intermediate
Data structure tree - intermediate
MD. MARUFUZZAMAN .
 
Data structure tree- advance
Data structure tree- advanceData structure tree- advance
Data structure tree- advance
MD. MARUFUZZAMAN .
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
Muhazzab Chouhadry
 
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
Intro C# Book
 
Binary tree
Binary treeBinary tree
Binary tree
Maria Saleem
 
Data Structures
Data StructuresData Structures
Data Structures
Nitesh Bichwani
 
part4-trees.ppt
part4-trees.pptpart4-trees.ppt
part4-trees.ppt
Suneel61
 
Binary Search Tree Traversal.ppt
Binary Search Tree Traversal.pptBinary Search Tree Traversal.ppt
Binary Search Tree Traversal.ppt
Riannel Tecson
 
Binary Trees.ppt
Binary Trees.pptBinary Trees.ppt
Binary Trees.ppt
Riannel Tecson
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
Intro C# Book
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
varagilavanya
 
R-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresR-Trees and Geospatial Data Structures
R-Trees and Geospatial Data Structures
Amrinder Arora
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
Radhika Puttewar
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .ppt
poonamsngr
 
Trees in data structrures
Trees in data structruresTrees in data structrures
Trees in data structrures
Gaurav Sharma
 
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
DATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptxDATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptx
AryaMNair6
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
maamir farooq
 

Similar to Tree in data structure (20)

Data structure tree - beginner
Data structure tree - beginnerData structure tree - beginner
Data structure tree - beginner
 
Data structure tree - intermediate
Data structure tree - intermediateData structure tree - intermediate
Data structure tree - intermediate
 
Data structure tree- advance
Data structure tree- advanceData structure tree- advance
Data structure tree- advance
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
 
Binary tree
Binary treeBinary tree
Binary tree
 
Data Structures
Data StructuresData Structures
Data Structures
 
part4-trees.ppt
part4-trees.pptpart4-trees.ppt
part4-trees.ppt
 
Binary Search Tree Traversal.ppt
Binary Search Tree Traversal.pptBinary Search Tree Traversal.ppt
Binary Search Tree Traversal.ppt
 
Binary Trees.ppt
Binary Trees.pptBinary Trees.ppt
Binary Trees.ppt
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
 
Trees
TreesTrees
Trees
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
 
R-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresR-Trees and Geospatial Data Structures
R-Trees and Geospatial Data Structures
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .ppt
 
Trees in data structrures
Trees in data structruresTrees in data structrures
Trees in data structrures
 
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
 
DATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptxDATA STUCTURES-TREES.pptx
DATA STUCTURES-TREES.pptx
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 

Recently uploaded

The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
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
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
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
 
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
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
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
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
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...
 
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
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

Tree in data structure

  • 2. DATA STRUCTURE Store and organize data in computer. Linear Data Structure Arrays Linked List Stacks Queues 2
  • 3. LOGIC OF TREE Used to represent hierarchica data. Shuvo(CEO) Shawon(CTO ) Tarun(Presedent) Bithi Moni Sila Rashel Raj Dola Shakila Riaj Shakib 3
  • 4. Used to represent hierarchical data. Shuvo(CEO) Shawon(CTO ) Tarun(Presedent) Bithi Moni Sila Rashel Raj Dola Shakila Riaj Shakib 4
  • 5.  A Collection of entities called Nodes.  Tree is a Non-Linear Data Structure.  It’s a hierarchica Structure. TREE Nodes 5
  • 6. Root-The top most Node. Children Parents Siblings- Have same parents. Leaf- Has no Child. RELATION OF TREE 1 3 2 4 6 5 8 7 11109 6
  • 7. EDGES, DEPTH, HEIGHT  Edges: If a tree have N nodes It have N-1 edges.  Depth of x: Length of path from Root to x.  Hight of x: No. Of edges in longest Path from x to a leaf Nodes Leaf7
  • 8. SOME APPLICATION OF TREE IN COMPUTER SCIENCE 1. Storing naturally hierarchicl data- File system. 2. Organige data for quick search, insertion, deletion- Binary search tree. 3. Dictionary 4. Network Routing Algorithm. 8
  • 9. Each node can have at most 2 childern. A node have only left and right child or Only left child or Only right child. A leaf node has no left or right child. A leaf node has only NULL. BINARY TREE Root Right- child of root. Left-child of root Leaf NULL9
  • 10. STRICT/PROPER BINARY TREE Each node can have either 2 or 0 child Root 10
  • 11. COMPLETE BINARY TREE  The last level is completely filled.  All nodes are as left as possible. Root L-2 L-3 L-4 L-1 11
  • 12. PARFECT BINARY TREE All the levels are comletely filled. Root L-2 L-3 L-1 12
  • 13. WE CAN IMPLEMENT BINARY TREE USING A) Dynamically created nodes. struct node { int data; struct node* left; struct node* right } 2 4 6 13
  • 14. OR 0 1 2 3 4 5 6 B) Arrays: It only works “complete Binary tree”. For node at index i; Left-child-index=2i+1 Right-child-index=2i+2 2 4 1 5 8 7 9 14
  • 15. IMPLEMENT OF BINARY SEARCH TREE Value of all the nodes in left subtree is Lesser or Equal. Value of all the nodes in right subtree is greater. Left-Subtree Right-Subtree (Lesser) (Greater) 15
  • 16. EXAMPLE  15>10-Left  15<20-Right  10>8-Left  10<12-Right  20>17-Left  20<25-Right 15 2010 12 258 17 Root 16
  • 17. BINARY TREE TRAVERSAL Tree traversal Breadth-first or Lever-order F,D,J,B,E,G,K,A,C,I,H Depth-first Preorder, Inorder & Postorder F JD I E KB G A C Root H 17
  • 18. PREORDER(DLR) Data Left Right <root><left><right> F,D,B,A,C,E,J,G,I,H,K Void Postorder(struct bstnode* root) { if(root==NULL) Postorder(root->right); Postordrt(root->right); printf(“%c”,root->data); } F JD I E KB G A C Root H 18
  • 19. INORDER(LDR) Left Data Right <left><root><right> A,B,C,D,E,F,G,H,I,J,K Void Inorder(struct bstnode* root) { if(root==NULL) return; Inorder(root->left); printf(“%c”,root->data); Inorder(root->right); } F JD I E KB G A C Root H 19
  • 20. POSTORDER(LRD) Left Right Data <left><right><root> A,C,B,E,D,H,I,G,K,J,F,A,B Void Postorder(struct bstnode* root) { if(root==NULL) Postorder(root->right); Postordrt(root->right); printf(“%c”,root->data); } F JD I E KB G A C Root H 20
  • 21. SEARCH AN ELEMENT IN BST bool Search( bstnode* root, data type) { if (root==NULL) return false; else if(root->data == data) return true; else if(root->data <= data) return Search(root->left, data); else return Search(root->right, data); } 12 155 14 7 173 13 8 11 Root 21
  • 22. DLELETE A NODE FROM BST  There are three items to delete.  Case 1: No Child  Case 2: One Child  Case 3: Two Child 12 155 14 7 173 13 8 11 Root 22
  • 23. CASE 1: NO CHILD  Remove to reference of the Node  From it’s parent &  Return NULL 12 155 14 7 173 13 8 11 Root 23
  • 24. CASE 2: ONE CHILD  Find the Node to Delete  Link it’s parent to this only child.  Remain attached to the tree. 12 155 14 7 173 13 8 11 Root 24
  • 25. CASE 3: TWO CHILD Two way to delete. 1. Find minimum in right Copy the value in targetted node Delete duplicate from right subtree. 12 155 14 7 173 13 8 11 Root 25
  • 26. CASE 3: TWO CHILD 2. Find maximum in left Copy the value in targetted node Delete duplicate from left-subtree. 12 155 14 7 173 13 8 11 Root 26
  • 27. RUNNING TIME OF OPERATION Operation Array Link List Binary Search Tree(average case) Search(x)-Search for an element x. O(Log n) O(n) O(Log n) Insertion(x)-Insert an element x. O(n) O(1) O(Log n) Remove(x)- Remove an element x. O(n) O(n) O(Log n) 27
  • 28. 28