The document discusses various types of tree data structures, including binary trees and binary search trees. It provides examples of how to implement binary search trees using a Node class, including how to search, insert, and delete nodes. It also discusses tree traversal algorithms and other applications of trees such as parsing, XML representation, and graphs.
Presentation On Binary Search Tree using Linked List Concept which includes Traversing the tree in Inorder, Preorder and Postorder Methods and also searching the element in the Tree
Presentation On Binary Search Tree using Linked List Concept which includes Traversing the tree in Inorder, Preorder and Postorder Methods and also searching the element in the Tree
In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited. The following algorithms are described for a binary tree, but they may be generalized to other trees as well.
In computer science, a tree is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.
1) Tree
2) General Tree
3) Binary Tree
4) Full Binay Tree, Complete Binay Tree
5) Binary Tree Traversal (DFS & BFS)
6) Binary Search Tree
7) Reconstruction of Binay Tree
8) Expression Tree
9) Evaluation of postfix expression
10) Infix to Prefix using stack
11) Infix to Postfix using stack
12) Threaded Binary Tree
13) AVL-Tree
14) AVL-Tree Rotation
Content of slide
Tree
Binary tree Implementation
Binary Search Tree
BST Operations
Traversal
Insertion
Deletion
Types of BST
Complexity in BST
Applications of BST
In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited. The following algorithms are described for a binary tree, but they may be generalized to other trees as well.
In computer science, a tree is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.
1) Tree
2) General Tree
3) Binary Tree
4) Full Binay Tree, Complete Binay Tree
5) Binary Tree Traversal (DFS & BFS)
6) Binary Search Tree
7) Reconstruction of Binay Tree
8) Expression Tree
9) Evaluation of postfix expression
10) Infix to Prefix using stack
11) Infix to Postfix using stack
12) Threaded Binary Tree
13) AVL-Tree
14) AVL-Tree Rotation
Content of slide
Tree
Binary tree Implementation
Binary Search Tree
BST Operations
Traversal
Insertion
Deletion
Types of BST
Complexity in BST
Applications of BST
CA in Patna is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Patna.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
CA in Patna is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Patna.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
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
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