Question

Question: Algorithms and data structures | Red black trees Create red black trees based on given...

Question: Algorithms and data structures | Red black trees

Create red black trees based on given conditions

Note: (A, B, C, D, E) should be the only nodes used

B is the root node

Complete the following four cases by drawing the tree

Assume: x is black and is a right child.

The case where x is black and a right left is similar (symmetric).

Four cases:

x’ sibling w is red.

x’s sibling w is black; both children of w are black.

x’s sibling w is black; right child of w is red, left child black.

x’s sibling w is black; left child of w is red.

COMPLETE:

x is a black right child: Case 1

x’ sibling w is red.

Right rotate on B (parent) ; change colors of B (parent) and D (sibling).

Transform to Case 2, 3, or 4 (where w is black).

----------

x is a black right child : Case 2

x’s sibling w is black; both children of w are black.

Move x up, and change w’s color to red.

If new x is red, change it to black; else, repeat.

-----------

x is a black right child : Case 3

x’s sibling w is black; w’s right child is red (C) , left child black.

Left rotate on w (D); switch colors of C (child) and D (sibling).

C (child) becomes the new w.

Transform to Case 4.

-----------

X is a black Right child : Case 4

x’s sibling w is black; w’s left child (E) is red.

Right rotate on B (parent) ; switch colors of B (parent) and D (sibling) ;

change E (child) to black.

Done!

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

There are total 4 classes. Student class is inherited and publicly accessed by 2 more classesFirstYearStudent and SecondYearStudent and there is 1 more School class. So total 4 classes

In main function when School object is called 100 constructors from FirstYearStudent of Student and 100constructors from SecondYearStudent of Student and 1 of school constructor and 100 constructor of FirstYearStudent itself and 100 constructors of SecondYearStudent which means s a total of 401 objects will be created because 401 will be created.

Add a comment
Know the answer?
Add Answer to:
Question: Algorithms and data structures | Red black trees Create red black trees based on given...
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
  • Red black trees Perform insertions of the following keys, 4, 7, 12, 15, 3, 5, 14,...

    Red black trees Perform insertions of the following keys, 4, 7, 12, 15, 3, 5, 14, 18, 16, 17 (left to right) into a redblack tree, then, perform deletions of keys 3, 12, 17, under the properties as provided below. • Root propoerty: the root is black. • External propoerty: every leaf is black. • Internal propoerty: the children of a red node are black. • Depth propoerty: all the leaves have the same black depth. Note that insertions have...

  • For each of the following statements about red-black trees, determine whether it is true or false....

    For each of the following statements about red-black trees, determine whether it is true or false. If you think it is true, provide a justification. If you think it is false, give a counterexample. a. A subtree of a red-black tree is itself a red-black tree. b. The sibling of an external node is either external or it is red. c. Given a red-black tree T, there is an unique (2,4) tree T associated with T. d. Given a (2,4)...

  • 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...

  • 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...

  • Balanced Trees Identify the correctness of each of the following statements by marking either a T...

    Balanced Trees Identify the correctness of each of the following statements by marking either a T for true of F for false 1. (1 point)A balanced tree is exclusively defined as one in which the height of each sub-tree (or child) differs by no more than one (1). 2. (1 point)In a red-black tree, after rotating three nodes, the two children will each be red. 3. (1 point) One will only ever need to perform one rotation or color-flip in...

  • just need to answer the second question 3 AVL Trees Assume the following notation/operations on AVL trees....

    just need to answer the second question 3 AVL Trees Assume the following notation/operations on AVL trees. An empty AVL tree is denoted E. A non-empty AVL tree T has three attributes: . The key T.key is the root node's key. The left child T.left is T's left subtree, which is an AVL tree (possibly E). The right child T.right is T's right subtree, which is an AVL tree (possibly E) [3 marks] Describe an alternative version of the RANGECOUNT(T,...

  • A balanced binary tree is a binary tree structure in which the left and right subtrees of every node differ

    Data structures C++1- A balanced binary tree is a binary tree structure in which the left and right subtrees of every node differ in height by no more than 1 Out of the following choices, which is the minimum set of nodes, if removed, will make the BST balanced?2- Which of the following is true for Red-Black Trees ? Select all choices that apply! Select one or more: a. For each node in the tree, all paths from that node to any leaf nodes contain...

  • You will construct a Huffman tree based on the given frequencies of 26 English alphabets in...

    You will construct a Huffman tree based on the given frequencies of 26 English alphabets in upper case plus the space character. An internal tree node class in HuffmanTree with necessary information is required. • You will not randomly switch left and right children when merger two trees. Instead, you will build a right-heavy tree according to the following strategies to select the right child. (1) The tree that is taller will be the right child, i.e., the height is...

  • Need help in the below question. Answer in java Start with the tree.java program (Listing 8.1)...

    Need help in the below question. Answer in java Start with the tree.java program (Listing 8.1) and modify it to create a binary tree from a string of letters (like A, B, and so on) entered by the user. Each letter will be displayed in its own node. Construct the tree so that all the nodes that contain letters are leaves. Parent nodes can contain some non-letter symbol like +. Make sure that every parent node has exactly two children....

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