The document discusses AVL trees, which are self-balancing binary search trees. It provides information on AVL tree operations like insertion and deletion of nodes. Insertion may cause imbalance, requiring rotation operations like single, double, left, or right rotations to rebalance the tree. Deletion is similar but can require propagating rotations upward to restore balance. AVL trees provide O(log n) time for operations by staying balanced through rebalancing rotations after inserts and deletes.
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking
Breadth First Search & Depth First SearchKevin Jadiya
The slides attached here describes how Breadth first search and Depth First Search technique is used in Traversing a graph/tree with Algorithm and simple code snippet.
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking
Breadth First Search & Depth First SearchKevin Jadiya
The slides attached here describes how Breadth first search and Depth First Search technique is used in Traversing a graph/tree with Algorithm and simple code snippet.
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
YouTube Link: https://youtu.be/amlkE0g-YFU
** Artificial Intelligence and Deep Learning: https://www.edureka.co/ai-deep-learni... **
This Edureka PPT on 'A Star Algorithm' teaches you all about the A star Algorithm, the uses, advantages and disadvantages and much more. It also shows you how the algorithm can be implemented practically and has a comparison between the Dijkstra and itself.
Check out our playlist for more videos: http://bit.ly/2taym8X
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
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
AVL Trees
Adelson-Velskii and Landis
Binary Search Tree - Best Time
All BST operations are O(d), where d is tree depth
minimum d is for a binary tree with N nodes
What is the best case tree?
What is the worst case tree?
So, best case running time of BST operations is O(log N)
Binary Search Tree - Worst Time
Worst case running time is O(N)
What happens when you Insert elements in ascending order?
Insert: 2, 4, 6, 8, 10, 12 into an empty BST
Problem: Lack of “balance”:
compare depths of left and right subtree
Unbalanced degenerate tree
Balanced and unbalanced BST
Approaches to balancing trees
Don't balance
May end up with some nodes very deep
Strict balance
The tree must always be balanced perfectly
Pretty good balance
Only allow a little out of balance
Adjust on access
Self-adjusting
Balancing Binary Search Trees
Many algorithms exist for keeping binary search trees balanced
Adelson-Velskii and Landis (AVL) trees (height-balanced trees)
Splay trees and other self-adjusting trees
B-trees and other multiway search trees
Perfect Balance
Want a complete tree after every operation
tree is full except possibly in the lower right
This is expensive
For example, insert 2 in the tree on the left and then rebuild as a complete tree
AVL - Good but not Perfect Balance
AVL trees are height-balanced binary search trees
Balance factor of a node
height(left subtree) - height(right subtree)
An AVL tree has balance factor calculated at every node
For every node, heights of left and right subtree can differ by no more than 1
Store current heights in each node
Height of an AVL Tree
N(h) = minimum number of nodes in an AVL tree of height h.
Basis
N(0) = 1, N(1) = 2
Induction
N(h) = N(h-1) + N(h-2) + 1
Solution (recall Fibonacci analysis)
N(h) > h ( 1.62)
Height of an AVL Tree
N(h) > h ( 1.62)
Suppose we have n nodes in an AVL tree of height h.
n > N(h) (because N(h) was the minimum)
n > h hence log n > h (relatively well balanced tree!!)
h < 1.44 log2n (i.e., Find takes O(logn))
Node Heights
Node Heights after Insert 7
Insert and Rotation in AVL Trees
Insert operation may cause balance factor to become 2 or –2 for some node
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Single Rotation in an AVL Tree
Implementation
Single Rotation
Double Rotation
Implement Double Rotation in two lines.
Insertion in AVL Trees
Insert at the leaf (as for all BST)
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Insert in BST
Insert in AVL trees
Example of Insertions in an A
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
YouTube Link: https://youtu.be/amlkE0g-YFU
** Artificial Intelligence and Deep Learning: https://www.edureka.co/ai-deep-learni... **
This Edureka PPT on 'A Star Algorithm' teaches you all about the A star Algorithm, the uses, advantages and disadvantages and much more. It also shows you how the algorithm can be implemented practically and has a comparison between the Dijkstra and itself.
Check out our playlist for more videos: http://bit.ly/2taym8X
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
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
AVL Trees
Adelson-Velskii and Landis
Binary Search Tree - Best Time
All BST operations are O(d), where d is tree depth
minimum d is for a binary tree with N nodes
What is the best case tree?
What is the worst case tree?
So, best case running time of BST operations is O(log N)
Binary Search Tree - Worst Time
Worst case running time is O(N)
What happens when you Insert elements in ascending order?
Insert: 2, 4, 6, 8, 10, 12 into an empty BST
Problem: Lack of “balance”:
compare depths of left and right subtree
Unbalanced degenerate tree
Balanced and unbalanced BST
Approaches to balancing trees
Don't balance
May end up with some nodes very deep
Strict balance
The tree must always be balanced perfectly
Pretty good balance
Only allow a little out of balance
Adjust on access
Self-adjusting
Balancing Binary Search Trees
Many algorithms exist for keeping binary search trees balanced
Adelson-Velskii and Landis (AVL) trees (height-balanced trees)
Splay trees and other self-adjusting trees
B-trees and other multiway search trees
Perfect Balance
Want a complete tree after every operation
tree is full except possibly in the lower right
This is expensive
For example, insert 2 in the tree on the left and then rebuild as a complete tree
AVL - Good but not Perfect Balance
AVL trees are height-balanced binary search trees
Balance factor of a node
height(left subtree) - height(right subtree)
An AVL tree has balance factor calculated at every node
For every node, heights of left and right subtree can differ by no more than 1
Store current heights in each node
Height of an AVL Tree
N(h) = minimum number of nodes in an AVL tree of height h.
Basis
N(0) = 1, N(1) = 2
Induction
N(h) = N(h-1) + N(h-2) + 1
Solution (recall Fibonacci analysis)
N(h) > h ( 1.62)
Height of an AVL Tree
N(h) > h ( 1.62)
Suppose we have n nodes in an AVL tree of height h.
n > N(h) (because N(h) was the minimum)
n > h hence log n > h (relatively well balanced tree!!)
h < 1.44 log2n (i.e., Find takes O(logn))
Node Heights
Node Heights after Insert 7
Insert and Rotation in AVL Trees
Insert operation may cause balance factor to become 2 or –2 for some node
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Single Rotation in an AVL Tree
Implementation
Single Rotation
Double Rotation
Implement Double Rotation in two lines.
Insertion in AVL Trees
Insert at the leaf (as for all BST)
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Insert in BST
Insert in AVL trees
Example of Insertions in an A
Binary search tree.
Balancedand unbalanced BST.
Approaches to balancing trees.
Balancing binary search trees.
Perfect balance.
Avl trees 1962.
Avl good but both perfect balance.
Height of an AVL tree
Nood
AVL Tree in Data Structures- It is height balanced tree with balance factor 1, -1 or 0. The different type of rotations used in this tree are: RR, LL, RL, LR
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
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
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.
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
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
2. Binary Search Tree - Best Time
• All BST operations are O(h), where h is tree
height
• minimum h is O(log n) for a binary tree with
N nodes
– What is the best case tree? O(log n)
– What is the worst case tree? O(n)
• So, best case running time of BST operations
is O(log N)
2
3. Binary Search Tree - Worst Time
• Worst case running time is O(N)
– What happens when you Insert elements in
ascending order?
• Insert: 2, 4, 6, 8, 10, 12 into an empty BST
– Problem: Lack of “balance”:
• compare depths of left and right subtree
– Unbalanced degenerate tree
3
5. Approaches to balancing trees
• Don't balance
– May end up with some nodes very deep
• Strict balance
– The tree must always be balanced perfectly
• Pretty good balance
– Only allow a little out of balance
5
6. Balancing Binary Search Trees
• Many algorithms exist for keeping binary
search trees balanced
– Adelson-Velskii and Landis (AVL) trees (height-
balanced trees)
– Splay trees and other self-adjusting trees
– B-trees and other multiway search trees
6
7. Perfect Balance
• Want a complete tree after every operation
– tree is full except possibly in the lower right
• This is expensive
– For example, insert 2 in the tree on the left and
then rebuild as a complete tree
7
Insert 2 &
complete tree
6
4 9
81 5
5
2 8
6 91 4
8. AVL - Good but not Perfect Balance
• AVL trees are height-balanced binary search
trees
• Balance factor of a node
– height(left subtree) - height(right subtree)
• An AVL tree has balance factor calculated at
every node
– For every node, heights of left and right subtree
can differ by no more than 1
– Store current balance in each node
8
9. Implementation
9
balance (1,0,-1)
key
rightleft
No need to keep the height; just the difference in height,
i.e. the balance factor; this has to be modified on the path of
insertion even if you don’t perform rotations
Once you have performed a rotation (single or double) you won’t
need to go back up the tree
11. Node Heights
11
1
00
2
0
6
4 9
81 5
1
height of node = h
balance factor = hleft-hright
empty height = -1
0
0
height=2 BF=1-0=1
0
6
4 9
1 5
1
Tree A (AVL) Tree B (AVL)
12. Node Heights after Insert 7
12
2
10
3
0
6
4 9
81 5
1
height of node = h
balance factor = hleft-hright
empty height = -1
1
0
2
0
6
4 9
1 5
1
0
7
0
7
balance factor
1-(-1) = 2
-1
Tree A (AVL) Tree B (not AVL)
13. Insert and Rotation in AVL Trees
• Insert operation may cause balance factor to
become 2 or –2 for some node
– only nodes on the path from insertion point to
root node have possibly changed in height
– So after the Insert, go back up to the root node by
node, updating heights
– If a new balance factor (the difference hleft-hright) is
2 or –2, adjust tree by rotation around the node
13
14. Inserting a Node in an AVL Tree
• During insertion, the new node is inserted as the leaf node, so it will
always have balance factor equal to zero.
• The nodes whose balance factors will change are those which lie on
the path between the root of the tree and the newly inserted node.
• The possible changes which may take place in any node on the path
are as follows:
Initially the node was either left or right heavy and after insertion has
become balanced.
Initially the node was balanced and after insertion has become either
left or right heavy.
Initially the node was heavy (either left or right) and the new node has
been inserted in the heavy sub-tree thereby creating an unbalanced
sub-tree. Such a node is said to be a critical node.
15. Single Rotation in an AVL Tree
15
2
10
2
0
6
4 9
81 5
1
0
7
0
1
0
2
0
6
4
9
8
1 5
1
0
7
17. 17
Let the node that needs rebalancing be .
There are 4 cases:
Outside Cases (require single rotation) :
1. Insertion into left subtree of left child of .
2. Insertion into right subtree of right child of .
Inside Cases (require double rotation) :
3. Insertion into right subtree of left child of .
4. Insertion into left subtree of right child of .
The rebalancing is performed through four
separate rotation algorithms.
Insertions in AVL Trees
18. Rotations to Balance AVL Trees
• To perform rotation, our first work is to find the critical node. Critical node is
the nearest ancestor node on the path from the root to the inserted node
whose balance factor is neither -1, 0 nor 1.
• The second task is to determine which type of rotation has to be done.
• There are four types of rebalancing rotations and their application depends on
the position of the inserted node with reference to the critical node.
LL rotation: the new node is inserted in the left sub-tree of the left sub-tree of
the critical node
RR rotation: the new node is inserted in the right sub-tree of the right sub-tree
of the critical node
LR rotation: the new node is inserted in the right sub-tree of the left sub-tree
of the critical node
RL rotation: the new node is inserted in the left sub-tree of the right sub-tree
of the critical node
34. Insertion in AVL Trees
• Insert at the leaf (as for all BST)
– only nodes on the path from insertion point to
root node have possibly changed in height
– So after the Insert, go back up to the root node by
node, updating heights
– If a new balance factor (the difference hleft-hright) is
2 or –2, adjust tree by rotation around the node
34
42. 5
4
2 7
151 3 6
1614
Fig 16
4
2 6
151 3 5
16
7
14
Fig 15
Deletions can be done with similar rotations
43. AVL Tree Deletion
• Similar but more complex than insertion
– Rotations and double rotations needed to
rebalance
– Imbalance may propagate upward so that many
rotations may be needed.
43
44. 44
Arguments for AVL trees:
1. Search is O(log N) since AVL trees are always balanced.
2. Insertion and deletions are also O(logn)
3. The height balancing adds no more than a constant factor to the
speed of insertion.
Arguments against using AVL trees:
1. Difficult to program & debug; more space for balance factor.
2. Asymptotically faster but rebalancing costs time.
3. Most large searches are done in database systems on disk and use
other structures (e.g. B-trees).
4. May be OK to have O(N) for a single operation if total run time for
many consecutive operations is fast (e.g. Splay trees).
Pros and Cons of AVL Trees
45. Deleting a Node from an AVL Tree
• Deletion of a node in an AVL tree is similar to that of binary search trees.
• But deletion may disturb the AVLness of the tree, so to re-balance the
AVL tree we need to perform rotations.
• There are two classes of rotation that can be performed on an AVL tree
after deleting a given node: R rotation and L rotation.
• If the node to be deleted is present in the left sub-tree of the critical
node, then L rotation is applied else if node is in the right sub-tree, R
rotation is performed.
• Further there are three categories of L and R rotations. The variations of
L rotation are: L-1, L0 and L1 rotation. Correspondingly for R rotation,
there are R0, R-1 and R1 rotations.
46. Deleting a Node from an AVL Tree
• R0 Rotation
Let B be the root of the left or right sub-tree of A (critical node).
R0 rotation is applied if the balance factor of B is 0.
Consider the AVL tree given below and delete 72 from it.
4
5
6
3
3
6
2
7 3
9
7
2
-1
1
1
-1
0
1
8
0
4
0
0
0
45
6336
27 39
0
2
1
-1
0
18 40
0 0
36
4527
18
39
1
-1
0
-1
1
40
63
0
0
47. Deleting a Node from an AVL Tree
• R1 Rotation
Let B be the root of the left or right sub-tree of the critical node.
R1 rotation is applied if the balance factor of B is 1.
Consider the AVL tree given below and delete 72 from it.
4
5
6
3
3
6
2
7 3
9
7
2
1
1
1
0
1
1
8
0
0
45
6336
27 39
0
2
1
0
1
18
0
3
6
4
5
2
7
1
8
3
9
0
0
0 0
1
6
3
0
48. Deleting a Node from an AVL Tree
• R-1Rotation
Let B be the root of the left or right sub-tree of the critical node.
R-1 rotation is applied if the balance factor of B is -1.
Consider the AVL tree given below and delete 72 from it.
4
5
6
3
3
6
2
7 3
9
-1
1
0 0
-1
3
7
4
1
0 0
7
2
0
4
5
6
3
3
6
2
7 3
9
0
2
0 0
-1
3
7
4
1
0 0
3
9
4
5
3
6
2
7
3
7
4
1
1
1
1 0
1
0
6
3
0