Question

2.1. Insert 85 into the following red-black tree. Show all your steps. (Note that the leaves (nil) are not shown) 33 o = blac

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

2.1) Given Red - black Tree is

0033 0020 000 0007 0026 0050 0030 0070 000

Insert 85:

85 > 33, 60, 80 go to Right Subtree

85  < 90 go to Left Subtree

0033 0020 0050 0007 0025 0050 00:30 0070 0190 0085

Node and Parent are both Red.Uncle of node is Red Push Blackness down from grand Parent0033 0020 006 0007 0026 0050 0050 0070 0030 0085

Node and Parent are both Red.Node is Right child Parent is Right child so Perform Single Rotate Left

0060 0033 0080 0020 0050 0070 0090 0007 0026 0035

Root of the Tree is Red Color it Black

0051 0033 0080 0020 0050 0070 0090 0007 0026 0035

Which is Required Red/Black Tree after Insertion of 85

2.2) Given Red - black Tree is

0033 0020 000 0007 0026 0050 0080 0005 0015 0022 0030

Insert 23:

23 < 33 go to Left Subtree
23 > 20 go to Right Subtree   
23 < 26 go to Left Subtree
23 > 22 go to Right Subtree   

0033 0020 0060 000/ 0025 0050 0050 0005 0015 0022 0030 0023

Node and Parent are both Red.Uncle of node is Red Push Blackness down from grand Parent

0033 0020 0050 0007 0026 0050 0030 0005 0015 0022 0030 0023

Node and Parent are both Red.Node is Right child Parent is Left child so Perform Single Rotate Left

0033 0026 0060 0020 0030 0050 0080 0007 0022 0005 0015 0023

Node and Parent are both Red.Node is Left child Parent is Left child So Perform Single Rotate Right

0026 0020 0033 000了 0022 0030 0050 0005 0015 0023 0050 0050

Root of the Tree is Red Color it Black

0026 0020 0033 000r 0022 0030 0050 0005 0015 0023 0050 0080

Which is Required Red/Black Tree after Insertion of 23

Add a comment
Know the answer?
Add Answer to:
2.1. Insert 85 into the following red-black tree. Show all your steps. (Note that the leaves...
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
  • Using the Red-Black Tree applet, you input the following numbers into the Red-Black tree, keep all...

    Using the Red-Black Tree applet, you input the following numbers into the Red-Black tree, keep all red-black rules (on page 433) either using color changes or rotation. The result graph should be height balance and red-black correct. (20 pts) Attach your results of screen shots for every question. Insert 50, 70, 20, 90 Insert 50, 70, 20, 90, 99 Insert 50, 70, 20, 90, 80 Insert 50, 70, 20, 80, 60, 90, 75, 95 Insert 50, 70, 20, 90, 60,...

  • (a) On an initially empty red-black tree, perform the following operations in this order: insert(1), insert(3),...

    (a) On an initially empty red-black tree, perform the following operations in this order: insert(1), insert(3), insert(5), insert(6), insert(7), delete(1) Show all the intermediate steps of your work (b) We can get another sorting algorithm by first inserting all the keys into a red-black tree, and then performing an in-order traversal of the tree. What's the time complexity of this algorithm? (As always, use O or Θ notation.)

  • 6. For the B+-tree where M=3 and L=5 shown below, show how an insert of value...

    6. For the B+-tree where M=3 and L=5 shown below, show how an insert of value 80 is handled. || 12 || 50 || / | \ / | \ 2 12 50 5 18 65 7 20 70 9 21 72 10 24 78 10 points 7. For the B+-tree where M=3 and L=5 shown below, show how an insert of value 28 is handled. || 24 || 75 || / | \ / | \ / | \...

  • 2-3-4 and Red Black Trees. Do these side by side: Insert the following into a 2-3-4...

    2-3-4 and Red Black Trees. Do these side by side: Insert the following into a 2-3-4 and Red black tree: {60, 56, 72, 39, 57, 41, 97, 85, 20, 18, 10, 16} (Show your steps etc.) Theory here Explain, from your own observation in a. what it means that the two trees are considered ‘equivalent’. Theory here

  • Num #2 Below, you are given a correct Red-Black tree, in which red nodes are shown...

    Num #2 Below, you are given a correct Red-Black tree, in which red nodes are shown as shaded diamonds, while black nodes are shown as empty circles. Give the final tree obtained from inserting the key '8 into this tree, after the insert function correctly restores the Red-Black Tree properties. It is not necessary to show intermediate steps, but if your final answer is wrong, you will get partial credit if earlier steps are correct. 4 (6 3 10

  • Q1: How many levels your binary search tree has (including level 0)? Is the binary search tree you created height balanc...

    Q1: How many levels your binary search tree has (including level 0)? Is the binary search tree you created height balanced? 2.1 Click the animations “Binary Search Tree”. Click “Insert” button to insert the following elements in the sequence, “50, 20, 30, 70, 90, 80, 40, 10, 5, 60, 85, 95”. http://algoanim.ide.sk/index.php?page=showanim&id=44 Q2: What is the insertion process of the binary search tree? The new identical element is inserted as left or right child of the existing same value? 2.3...

  • Question 4: Insert the following into B+ tree of order 3. Show your work step by...

    Question 4: Insert the following into B+ tree of order 3. Show your work step by step and show null pointer. 90, 22, 27, 24, 28, 20, 51, 63, 8, 80, 15, 71, 35, 55

  • Q1: How many levels your binary search tree has (including level 0)? Is the binary search...

    Q1: How many levels your binary search tree has (including level 0)? Is the binary search tree you created height balanced? 2.1 Click the animations “Binary Search Tree”. Click “Insert” button to insert the following elements in the sequence, “50, 20, 30, 70, 90, 80, 40, 10, 5, 60, 85, 95”. http://algoanim.ide.sk/index.php?page=showanim&id=44 Q2: What is the insertion process of the binary search tree? The new identical element is inserted as left or right child of the existing same value? 2.3...

  • Data Structure!!!!!!!!!! For the B+-tree where M=3 and L=5 shown below, show how an insert of...

    Data Structure!!!!!!!!!! For the B+-tree where M=3 and L=5 shown below, show how an insert of value 77 is handled. Use the method of splitting the node rather than redistributing between siblings. || 24 || 75 || / | \ / | \ / | \ || 10 || 16 || || 41 || 50 || || 84 || 90 || | / \ / | \ | \ \ / | | | | \ | | | 2...

  • For the B+-tree where M=3 and L=5 shown below, show how an insert of value 77...

    For the B+-tree where M=3 and L=5 shown below, show how an insert of value 77 is handled. Use the method of splitting the node rather than redistributing between siblings. || 24 || 75 || / | \ / | \ / | \ || 10 || 16 || || 41 || 50 || || 84 || 90 || | / \ / | \ | \ \ / | | | | \ | | | 2 10 16...

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