The document discusses balanced binary search trees, specifically AVL trees. It defines AVL trees as binary search trees where the heights of any node's left and right subtrees differ by at most one. It describes how insertions and deletions can cause the tree to become unbalanced and require rotations to restore the balance property. Rotations are classified based on the position of inserted/deleted nodes and include left-left, left-right, right-right, and right-left types. The time complexity of insertions and deletions in AVL trees is O(logN) due to rebalancing rotations after each operation.
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
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
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 is the first dynamic tree in data structure which minimizes its height during insertion and deletion operations. This is because searching time is directly proportional to the height of binary search tree (BST). When insertion operation is performed it may result into increasing the height of the tree and when deletion is performed it may result into decreasing the height. To make the BST a height balance tree (AVL tree) creators of the AVL tree proposed various rotations. This paper shows BST and its operation and AVL.
Definition of an AVL tree, Insertion of an AVL tree,Height of an AVL tree,Rotations in AVL tree,Representation of AVL tree,Deletion of an AVL tree,AVL search Tree, R0 rotation,R1 rotation,R-1 rotation in AVL tree
AVL tree ( Balanced Binary Search Tree)-Data StructureYaksh Jethva
An AVL tree is another balanced binary search tree.
DEFINITION: An AVL Tree is a height-balanced binary search tree.
DEFINITION: The balance factor of a binary tree is the difference in heights of its two subtrees (hR - hL).
The balance factor (bf) of a height balanced binary tree may take on one of the values -1, 0, +1.
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 is the first dynamic tree in data structure which minimizes its height during insertion and deletion operations. This is because searching time is directly proportional to the height of binary search tree (BST). When insertion operation is performed it may result into increasing the height of the tree and when deletion is performed it may result into decreasing the height. To make the BST a height balance tree (AVL tree) creators of the AVL tree proposed various rotations. This paper shows BST and its operation and AVL.
Definition of an AVL tree, Insertion of an AVL tree,Height of an AVL tree,Rotations in AVL tree,Representation of AVL tree,Deletion of an AVL tree,AVL search Tree, R0 rotation,R1 rotation,R-1 rotation in AVL tree
AVL tree ( Balanced Binary Search Tree)-Data StructureYaksh Jethva
An AVL tree is another balanced binary search tree.
DEFINITION: An AVL Tree is a height-balanced binary search tree.
DEFINITION: The balance factor of a binary tree is the difference in heights of its two subtrees (hR - hL).
The balance factor (bf) of a height balanced binary tree may take on one of the values -1, 0, +1.
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
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...ssuser7dcef0
Power plants release a large amount of water vapor into the
atmosphere through the stack. The flue gas can be a potential
source for obtaining much needed cooling water for a power
plant. If a power plant could recover and reuse a portion of this
moisture, it could reduce its total cooling water intake
requirement. One of the most practical way to recover water
from flue gas is to use a condensing heat exchanger. The power
plant could also recover latent heat due to condensation as well
as sensible heat due to lowering the flue gas exit temperature.
Additionally, harmful acids released from the stack can be
reduced in a condensing heat exchanger by acid condensation. reduced in a condensing heat exchanger by acid condensation.
Condensation of vapors in flue gas is a complicated
phenomenon since heat and mass transfer of water vapor and
various acids simultaneously occur in the presence of noncondensable
gases such as nitrogen and oxygen. Design of a
condenser depends on the knowledge and understanding of the
heat and mass transfer processes. A computer program for
numerical simulations of water (H2O) and sulfuric acid (H2SO4)
condensation in a flue gas condensing heat exchanger was
developed using MATLAB. Governing equations based on
mass and energy balances for the system were derived to
predict variables such as flue gas exit temperature, cooling
water outlet temperature, mole fraction and condensation rates
of water and sulfuric acid vapors. The equations were solved
using an iterative solution technique with calculations of heat
and mass transfer coefficients and physical properties.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
2. Balance Binary Search Tree
Worst case height of binary search tree: N
Insertion, deletion can be O(N) in the worst case
We want a tree with small height
Height of a binary tree with N node is at least Θ(log
N)
Goal: keep the height of a binary search tree O(log N)
Balanced binary search trees
Examples: AVL tree, red-black tree
3. Balanced Tree?
Suggestion 1: the left and right subtrees of root have the
same height
Suggestion 2: every node must have left and right
subtrees of the same height
Our choice: for each node, the height of the left and
right subtrees can differ at most 1,-1,0.
4. AVL Tree
An AVL (Adelson-Velskii and Landis 1962) tree is a
binary search tree in which
for every node in the tree, the height of the left and
right subtrees differ by at most 1.
AVL property
violated here
AVL tree
6. Height of AVL Tree
Denote Nh the minimum number of nodes in an AVL tree
of height h
N1=1, N2 =2 (base)
Nh= Nh-1 + Nh-2 +1 (recursive relation)
many operations (i.e. searching) on an AVL tree will
take O(log N) time
7. Insertion in AVL Tree
Basically follows insertion strategy of binary search
tree
But may cause violation of AVL tree property
Restore the destroyed balance condition if needed
6
7
6 8
Original AVL tree
Insert 6
Property violated
Restore AVL property
8. Some Observations
After an insertion, only nodes that are on the path from
the insertion point to the root might have their balance
altered
Because only those nodes have their subtrees altered
Rebalance the tree at the deepest such node guarantees
that the entire tree satisfies the AVL property
7
6 8
Rebalance node 7
guarantees the whole tree be AVL
6
Node 5,8,7 might
have balance altered
9. Different Rebalancing
Rotations
The rebalancing rotations are classified as LL, LR, RR
and RL as illustrated below, based on the position of
the inserted node with reference to α.
LL rotation: Inserted node is in the left subtree of the left
subtree of node α
RR rotation: Inserted node is in the right subtree of the
right subtree of node α
LR rotation: Inserted node is in the right subtree of the
left subtree of node α
RL rotation: Inserted node is in the left subtree of the
right subtree of node α
10. Insertion Analysis
Insert the new key as a new leaf just as in
ordinary binary search tree: O(logN)
Then trace the path from the new leaf towards
the root, for each node x encountered: O(logN)
Check height difference: O(1)
If satisfies AVL property, proceed to next node: O(1)
If not, perform a rotation: O(1)
The insertion stops when
A single rotation is performed
Or, we’ve checked all nodes in the path
Time complexity for insertion O(logN)
logN
11. Delete 5, Node 10 is unbalanced Single Rotation
20
10 35
40
15
5 25
18 45
38
30
50
20
15 35
40
18
10 25
45
38
30
50
Basically follows deletion strategy of binary search tree
But may cause violation of AVL tree property
Restore the destroyed balance condition if needed
12. For deletion, after rotation, we need to continue tracing
upward to see if AVL-tree property is violated at other node.
Different rotations are classified in R0, R1, R-1, L0, L1 And L-1
20
15 35
40
18
10 25
45
38
30
50
20
15
35
40
18
10
25 45
38
30 50
Continue to check parents
Oops!! Node 20 is
unbalanced!!
Single Rotation
13. Different rotations
• An element can be deleted from AVL tree which
may change the BF of a node such that it results
in unbalanced tree.
• Some rotations will be applied on AVL tree to
balance it.
• R rotation is applied if the deleted node is in the
right subtree of node A (A is the node with
balance factor other than 0, 1 and -1).
• L rotation is applied if the deleted node is in the
left subtree of node A.
14. Different rotations cont…
• Suppose we have deleted node X from the tree.
• A is the closest ancestor node on the path from X
to the root node, with a balance factor -2 or +2.
• B is the desendent of node A on the opposite
subtree of deleted node i.e. if the deleted node is
on left side the B is the desendent on the right
subtree of A or the root of right subtree of A.
15. R Rotation
• R Rotation is applied when the deleted node is in the right
subtree of node A.
• There are three different types of rotations based on the
balanced factor of node B.
• R0 Rotation: When the balance Factor of node B is 0.
• Apply LL Rotation on node A.
• R1 Rotation: When the balance Factor of node B is +1.
• Apply LL Rotation on node A.
• R-1 Rotation: When the balance Factor of node B is -1.
• Apply LR Rotation(RR rotation on B and LL rotation on
node A).
16. L Rotation
• L Rotation is applied when the deleted node is in the
left subtree of node A.
• There are three different types of rotations based on
the balanced factor of node B.
• L0 Rotation: When the balance Factor of node B is 0.
• Apply RR Rotation on node A.
• L-1 Rotation: When the balance Factor of node B is -1.
• Apply RR Rotation on node A.
• L1 Rotation: When the balance Factor of node B is +1.
• Apply RL Rotation(LL rotation on B and RR
rotation on node A).