Question

Answer the following questions about insertions into the Red-Black Tree shown above.

image.png

Answer the following questions about insertions into the Red-Black Tree shown above.

Important: This tree only works with integers between 1 and 35. Insert one integer into each box, no duplicates allowed.

Inserting _______ will cause a recolouring without a rotation.

Inserting _______ will cause a single rotation. The original root of the subtree rotated upon is _______ and the new root is _______ 

Inserting _______ will require multiple recolourings and/or rotations. In the final rotation, the original root of the subtree rotated upon is _______ and the new root is_______ 


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

# STAY HOME # STAY SAFE

If we insert 1 then its parent will be 2(red) and uncle will be 6(red) => Recoloring occurs without any rotation => 2 and 6 becomes black and 4 becomes red.

=> Inserting 1 will cause a recoloring without a rotation

If we insert 33 then its parent will be 34(red) and uncle is not present (black) => LL rotation will occur upon the subtree with root 35 and after rotation the new root will be 34.

=> Inserting 33 will cause a single rotation. The original root of the subtree rotated upon is 35 and the new root is 34.

If we insert 8 then its parent will be 9(red) and uncle will be 11(red) => Relocoring occurs => 9 and 11 becomes black and 10 becomes red. Now there is a red-red conflict between 10 and 12 => Rl rotation occurs upon 12 and the new root becomes 10.

=> Inserting 8 will require multiple recolorings and/ or rotations. In the final rotation the original root of the subtree rotated upon is 12 and the new root is 10.

Add a comment
Know the answer?
Add Answer to:
Answer the following questions about insertions into the Red-Black Tree shown above.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Select statements that are true about Red Black Tree (there may be more than one correct...

    Select statements that are true about Red Black Tree (there may be more than one correct answer): When node inserted its always red before other rules are applied Inserting into the Red-Black tree takes O(N) time One rotating operation that rotates 3 nodes in subtree takes O(1) time Searching Red-Black tree for a node takes O(Log N) time Recoloring is applied when inserting new node to a black parent

  • Create a communication information system for a company with using Red-Black Tree Method.

    PLEASE USE THE HEADER FILE THAT I ADDED TO THE END OF THE QUESTIONWrite this program with using C/C++, C#, Java or Python. Explain your code with comments. Create a communication information system for a company with using Red-Black Tree Method. Inthis system the users are allowed to search an employee from employee's registration number(id)and retreive the department number(id) and that employee's internal phone number. Also, if theemployee they are looking for is not in the tree, they can add it....

  • Create a communication information system for a company with using Red-Black Tree Method

    • Write this program with using C/C++, C#, Java or Python. Explain your code with comments. Create a communication information system for a company with using Red-Black Tree Method. Inthis system the users are allowed to search an employee from employee's registration number(id)and retreive the department number(id) and that employee's internal phone number. Also, if theemployee they are looking for is not in the tree, they can add it. (in accordance with the red-blacktree properties)a) Implement the Employee class:- Registration number...

  • please make a pretty JAVA GUI for this code this is RED BLACK TREE and i...

    please make a pretty JAVA GUI for this code this is RED BLACK TREE and i Finished code already jus need a JAVA GUI for this code ... if poosible make it pretty to look thanks and please make own GUI code base on my code thanks ex: (GUI only have to show RBTree) ---------------------------------------- RBTree.java import java.util.Stack; public class RBTree{    private Node current;    private Node parent;    private Node grandparent;    private Node header;    private Node...

  • must be coded in c++ without any STL libraries sadly :( so im struggling on this...

    must be coded in c++ without any STL libraries sadly :( so im struggling on this problem, any help would be greatly appreciated, thanks in advance! :) assignment is due tomorrow and im really struggling on this last question :( a. Begin by implementing a BST for integers. The underlying structure is a linked list. You need these methods: i. BST(); -- Constructor ii. void put (int) – Inserts a value into the BST. iii. Void put(int[] a) – Inserts...

  • Using C++, data structures, C++ STL, inputs and expected outputs are shown below. Max Heap Heap...

    Using C++, data structures, C++ STL, inputs and expected outputs are shown below. Max Heap Heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either > (in a max heap) or s (in a min heap) the key of C. The node at the "top" of the heap (with no parents) is called the root node. In binary-tree based heap, it...

  • JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...

    JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • Business Law: Text and Cases 14th Edition Please answer Number 3 I already have questions 1...

    Business Law: Text and Cases 14th Edition Please answer Number 3 I already have questions 1 and 2 answered. 1)   Assume you are the attorney for the Landlord. List the legal grounds under which you would sue the Tenants and list the arguments you would use to persuade the Judge to rule in your favor. Also list the defenses you would raise to the counterclaim brought by Tenants. Support your answers with legal reasoning and conclusions. The lease was for...

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