Question

a) Show balance factor of every node after each insertion by creating an AVL tree with...

a) Show balance factor of every node after each insertion by creating an AVL tree with 4,2,2,0,1,4,5,9,7,1,5,3,6 number. Express all operations (single/double rotation) necessary to restore the balance. b) Create min and max heap using the same input as in part (a) by showing all the necessary steps.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

Explanation:

keys = 4, 2, 2, 0, -, 4, 5, 9,7, t ,S, 3,6 empty las Inserting keys into free to create Avl tree. Balamingº Faites for all tr

Insest di ② (B-2) (B=2) ② U CB-0) L ILR rotation (B3-4) Double rotation R CB=0) dout Balan factor of dis q and hide & is a so

Insest Yi (3=0) t62) (hot) B=0 (Zec (1:0) Q ų (B=0) Insert s. (B = -I) B=22) RR rotation (1=0) ( single sotation) Q (8=-1) (B

Inserta: CB-2) (B=0) Ben) Gio (B=-2) RL retation (Double @ ( 64) (B-0) (10) rofeting (Bac) sofation to Balancing factor of mo

Innasi (-)) (B-) -1) (1:1) 62 (13= 1) (B=0) Plitleding (Deulle it latior) a) 16=0) L 00) © 113--1) +B) of mode 4 is -2 so mak

CH-0) 113=0) 13--)) @ (6-0) (B:1) (2281) lu (120) (B20) (1:0) tbt (Be) Inrest 6: 2).(6=-1) (133-10 th=-1) (1=80) (B1) (3-0) (

(6) keys = 4, 2, 2, 0, 1, 4, 5, 9, 7, 1,5, 3, 6. Creating min-heap: Insert 4: Incert 2 4 the as 2<4 haapifying Lakat L and he

2 again heapitying as oca, Swap & and 2 Insest gi 2 प Swap & and Li 4 losest 4 4 u

Insors u u Insest ai 9 40 Insest z Insest di ( I and 2 swap Heapitying

Inkof si 19 2 Insest 3 G Heapifying as 3 c4 ;swap 3 and 4 2

Infert 6: 9 (finall min-heap heap) max-he ? Creating heap Inserte: ų Insert Li ha 2 Insert L 4 (& Insesto:

brises di (4 A d Iridestul lų b) Hearitying as acy, swap & and y 4 Insert si Q Heapilying as 4 C5 I swap 4 and 5 (4

again swap 4 and 5 Intestai O (2) @ 0 and a Heapifying as ocq, swap q I and Again swap 4

Again swap 5 and q. (G Insenti 8 Swap 2 and 7. 9 e Again swap 5 and 7. 9

Insest di loisest 5: 9 Swap Swap r and 5 a @ Insest 3: 9

Swap Rut 3 v 9 3 U Insert i G 5 Sway 3 and to Q

Again swap чал.4 6: Э 4 4. а (final max-heap)

I have explained each and every part with the help of images attached to it.

Add a comment
Know the answer?
Add Answer to:
a) Show balance factor of every node after each insertion by creating an AVL tree with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT