
(a)
To explain the nodes that needs to change to insert a key k or delete a node y .
(a)

Explanation of Solution
For the insertion of the key k in the tree it first checks the ancestors of the tress then it traverses the children of that ancestor. The insertion causes some misbalancing situation so the tree needs to maintain the property of tree by changing the nodes.
The deletion of a node y is done by checking the children of the node y and the successor of the node y so that their children are placed into suitable node after deletion of the parent node y.
So, for the efficient execution of the operations it needs some changing in the ancestors of the node to accept the change by the insertion or deletion.
(b)
To gives an
(b)

Explanation of Solution
The algorithm for insertion in persistent tree is given below:
PERSISTENT-TREE-INSERT( T,k )
if
end if.
while
if
else
end if.
end while.
if
else
end if.
end.
The algorithm is used to insert a key k into the node. The algorithm checks the value of the nodes of the tree and then finds the suitable place to insert the key by comparing the value of key with the nodes of the tree.
The algorithm performs the insertion in such a way that it consider the root and start visiting the node of similar depth then it copy the nodes and then make new version of the tree with old and key k .
(c)
To explain the space required for the implementation of PERSISTENT-TREE-INSERT.
(c)

Explanation of Solution
The algorithm consists of the while loop that runs
The iterations of the algorithm run in constant time as they are just simple iteration or conditional iteration. For the purpose of storing all the h it needs some additional space equals to h .
Thus, the space and time required for the algorithm is depends upon the h and equals to
(d)
To prove that the PERSISTENT-TREE-INSERT would require
(d)

Explanation of Solution
The insertion of the a key into tree by using above algorithm is based on the fact that it first copy the original tree then it find the appropriate position for key and insert the key by addition key on the original tree.
The node that points to the appropriate position will copy and then it copy the ancestor of the node and so on until it copy all the connected nodes of the tree
The copying of a node takes constant time and one storage space for each node but there are total n nodes in the tree so it takes total time of n .
Thus, the algorithm takes total of
(e)
To explain the worse-case running time and space is
(e)

Explanation of Solution
The insertion or deletion of the key into tree cause dis-balancing in the tree so it needs to maintain the tree by changing the ancestors and children of the ancestors.
The algorithm allocates space of
For the finding the appropriate position it need to compare and check the values of node and for worse case it is equal to total nodes in
The operation is considering the ancestor of the node where the key is going to be inserted or deleted, the node with their children and ancestors are considered that is another subtree and for the worse case the height of that subtree is equal to the height of tree that is
Therefore, the total space and time requires for the operation is equals to
Want to see more full solutions like this?
Chapter 13 Solutions
Introduction to Algorithms
- Please solve and answer the questions correctly please. Thank you!!arrow_forwardConsidering the TM example of binary sum ( see attached)do the step-by-step of execution for the binary numbers 1101 and 11. Feel free to use the Formal Language Editor Tool to execute it; Write it down the current state of the tape (including the head position) and indicate the current state of the TM at each step.arrow_forwardI need help on inculding additonal code where I can can do the opposite code of MatLab, where the function of t that I enter becomes the result of F(t), in other words, turning the time-domain f(t) into the frequency-domain function F(s):arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning




