Consider a BST containing two nodes. 40 and 60. It is given that 40 is the root node. Now 80 is inserted in the BST. Identify the correct statement
Statement 1: RR rotation is best suited here to make the tree balanced
Statement 2 : After the Insertion, the tree has become Imbalanced
Statement 3: After the insertion the balance factor of exactly two nodes becomes negative
Statement 4: All statements are true
Options
Statement 1
OOO
Slalement 1 & 3
Statement 2 & 3
Slalement 4
Answers
Explanation:
hy guys
I am in leaderboard so I am informing u that
do not join any link given in brainly
kyuki brainly me hackers aaye h
vo kisi ki bhi id se aapka phone hack kr skte h
thank you
Statement 4 is the correct statement.
Explanation:
- Statement 1:RR rotation is best suited here to make the tree balanced.
BINARY SEARCH TREE is a node-based binary tree that further has right and left subtree that too is binary search tree, where right subtree is always greater than root and left subtree is always less than root.
If a BST contains two nodes and , given that is the root node. If we insert , the tree looks like this:
Hence, RR rotation is best suited here to make the tree balanced.
- Statement 2: After the Insertion, the tree has become Imbalanced.
After inserting , we see that the tree is right BST and the root node is imbalanced. The root node has a balance factor (balance factor: the difference between heights of left and right subtrees cannot be more than one for all nodes.)
- Statement 3: After the insertion the balance factor of exactly two nodes becomes negative.
The root node has a balanced factor
The balance factor of node is
Hence, After the insertion of root 80, the balance factor of exactly two nodes becomes negative.