Show each red-black tree that results after successively inserting the keys 4 7 12 15 3 5 14 18 into an initially empty red-black tree. At the steps were a red-black tree rule is violated, explain how it is corrected
Now delete these keys in this order and show each resultant red-black tree 18 15 7 14. At the steps were a red-black tree rule is violated, explain how it is corrected
Step 1: Insert keys 4 & 7
Step 2: Insert key 12

In above Tree Node and parent are both red. Node is
right child, parent is right child Can fix extra redness with a
single rotation
Perform Single Rotate Left

Step 3: Insert key 15

Node and parent are both red. Uncle of node is red — push blackness down from grandparent

Root of the tree is red.color it black

Step 4: Insert key 3
Step 5: Insert key 5

Step 6: Insert key 14

Node and parent are both red. Node is left child, parent is right child so Perform Rotate
Perform SIngle Rotate Right

Node and parent are both red. Node is right child, parent is right child Can fix extra redness with a single rotation

Perform SIngle Rotate Left

Step 7: Insert key 18

Node and parent are both red. Uncle of node is red so push blackness down from grandparent

Which is required Red-black tree after successively inserting the keys
Delete 18:
Node to delete is a leaf. Delete it

Delete 15:
Node to delete is a leaf. Delete it

Double black node has black sibling and 2 black nephews. Push up black level

Delete 7:
Node to delete has two childerr. Find largest node in
left subtree.

Copy largest value of left subtree into node to delete.

Remove the node whose value we copied
Deleted node was red. No tree rotations required

Delete 14:
Node to delete has no right child. Set parent of deleted
node to left child of deleted node.


Which is required Red-black tree after successively Deleting the keys
Show each red-black tree that results after successively inserting the keys 4 7 12 15 3...
Red-Black Tree: Show the sequence of red-black trees that result after successively inserting the keys into an initially empty red-black tree in the order given: K = < 20, 5, 1, 12, 7 >. (Show at least one tree resulting from each insertion). State which case from the textbook (Introduction to Algorithms, 3rd Edition by Thomas H. Cormen et al) applies. Assume that the root is always colored black.)
(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.)
Show the red-black tree using top-down insertion of the following keys: 12, 10, 15, 17, 19, 14, 16, and 18. Show the tree after each insertion.
Show the 2-3-4 tree after inserting the following keys: 12, 10, 15, 17, 19, 14, 16, 13, 22, 25, and 24. Show the tree after each insertion.
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...
Starting with an empty binary search tree, insert each of the following keys and rotate it to the root in the specified order: 6 1 18 7 15 Starting with an empty red-black binary search tree, insert the following keys in order:: 12 5 23 9 19 2 21 18 7 Show the tree immediately after you insert each key, and after each time you deal with one of the book's cases 1, 2, or 3 (that is, if dealing with one case leads to another, show the additional case as a...
Problem 6 Let T be a left-leaning red-black tree with integer keys. Show all the transformations involved in building T according to the following operations. See the example posted on the website for an example of how to show this. (You can draw these by hand.) put(o), put(1), put(2), put(3), put(4), delete(0), put(5), delete(1), delete(3), delete(5), put(3)
Write a program that builds t BSTs by inserting N random keys into an initially empty tree, and then finds the tree height for N =100, 500 and 1000; and t =5, 10, 15. Find the average height of binary search trees for each pair of values of t and N. Decide what you will do with duplicates and explain what you did to handle duplicates.
Trees and Heaps 1. Show that the maximum number of nodes in a binary tree of height h is 2h+1 − 1. 2. A full node is a node with two children. Prove that the number of full nodes plus one is equal to the number of leaves in a nonempty binary tree. 3. What is the minimum number of nodes in an AVL tree of height 15? 4. Show the result of inserting 14, 12, 18, 20, 27, 16,...
In this assignment, you will develop a C program to construct a red and black tree. For a given input sequence the tree is unique by using RB-INSERT on one number at a time. Below is an example: The input is a sequence of numbers separated by comma, e.g. 1,8,11,2, … You can enter the numbers using an input file and output the tree, or through a command line with one number at a time (with “X” to stop entering...