(a)
Explain the assumption that Line 7 can be performed in O(1) actual time.
(a)
Explanation of Solution
For performing line 7, the time taken is proportional to the number of children does x have. For adding each child in the root list requires to update the parent’s pointer to NULL instead of x.
Therefore, the updating of parent pointer to x is wrong in this assumption.
(b)
Give anupper bound on the actual time of PISANO-DELETE, when node x is not inH.min .
(b)
Explanation of Solution
An actual cost of bounded by x.degree and updating all children of x takes constant time so, the actual time of PISANO-DELETE is
Hence, the upper bound on the actual time is
(c)
Use PISANO-DELETE( H,x ), describe that the node x is not a root, bound the potential of H’ in terms of x.degree, c, t ( H ) and m ( H ).
(c)
Explanation of Solution
Explanation:
As given CASCASDING-CUT rule we know that if it marked more than one node then
If the children increased from the previous that x had then equation will become
Now taking the consideration and according to question, combiningthese expressions the bound of potential is −
(d)
Conclude that the amortized time for PISANO-DELETE is asymptotically no better than for FIB-DELETE, even when x
(d)
Explanation of Solution
The amortized time for PISANO-DELETE is asymptotically is
When x
Therefore, the amortized time for PISANO-DELETE is asymptotically no better than for FIB-DELETE, even when x
Want to see more full solutions like this?
Chapter 19 Solutions
Introduction to Algorithms
- 1.For a full binary tree, the number of leaf-nodes is more than non-leaf nodes. True False 2.For a Max-Heap, the functions Max and Extract-Max have same runtime complexity. True False 3.Heap-increase-Key and Heap-Decrease-Key both have same runtime complexity because both call Heapify function. True False 4.A sorted linked-list has fast insertion but slow extraction. True False 5.Don’t use Max-Heap in case you often perform search operation. Use sorted linked-list inserted. True Falsearrow_forwardAn insert adds a new single-node tree to the forest. So a sequence of n inserts into an initially empty heap will simply create n single-node trees. The cost of an insert is clearly O(1).A deleteMin operation removes the node indicated by minPtr. This turns all children of the removed node into roots. We then scan the set of roots (old and new) to find the new minimum, a potentially very costly process. We also perform some rebalancing, i.e., we combine trees into larger ones. The details of this process distinguish different kinds of addressable priority queue and are the key to efficiency.turn now to decreaseKey(h,k) which decreases the key value at a handle h to k. Of course, k must not be larger than the old key stored with h. Write algorithm for given statementarrow_forwardJava: Implementing the remove(u) Method for a Meldable Heap Implement the remove(u) method in Java, which removes the node u from a MeldableHeap. This method should run in O(log n) expected time. First, add the nodes (with values ranging from 1 to 15) to the Meldable Heap without using a scanner. Then, demonstrate that the remove(x) method effectively removes the specified node by printing the number of nodes remaining in the heap and the value of the node being removed. Please provide comments in the program to enhance understanding of its functionality.arrow_forward
- In java and in O(logn) time Write a method that balances an existing BST, call it balance(). A BST is balanced if the height of its left and right sub-trees are different by at most one. Recursively applied. If the tree is balanced, then searching for keys will take act like binary search and require only logn comparisons. No performance requirements on your balancing algorithm. (Come up with a way yourself - don't skip to 3.3. That section is really complicated and meant for the harder case where you need to do it in log time.)arrow_forwardIn the worst case, binary tree sort utilising a self-balancing binary search tree requires O(n log n) time, but it is still slower than merge sort.arrow_forwardAssume you are using a backtracking algorithm to search for the node 40 in the max heap represented by the array 100, 50, 60, 40, 10, 20, 30. Assuming that you search from the root of the heap downwards recursively, which of the following is a valid order in which the nodes could have been first visited? 30, 20, 10, 40 100, 50, 60, 10, 30, 40 100, 60, 30, 20, 50, 10, 40 100, 60, 50, 30, 20, 10, 40 100, 60, 30, 20, 10, 40 Assume you are using a backtracking algorithm to search for the node 40 in the max heap represented by the array 100, 50, 60, 40, 10, 20, 30. What is the minimum number of nodes that must be searched in order to find the node 30? 1 5 6 3 4 Assume you have the following backtracking algorithm for finding a way to a desired location in a city organized in a grid as represented by the image. What is the problem with this proposed algorithm? Bool SearchCity(currentLocation,, desiredLocation, stepsToLocation) { If(currentLocation == desiredLocation) { Return…arrow_forward
- Given a BST, which traversal method would allow you to turn it into a min heap using N heap insertions calls in O(N) worst case runtime? Draw an example of this process. First, draw a BST with 4 nodes and height of 3. You can pick the integer values in your BST. Then show the resulting traversal order, and a drawing of the values inserted into a min heap using N heap insertions. Redraw the heap after each insertion.arrow_forwardWrite a program that takes n elements as input and inserts them into a heap one by one. Include a function to print out the elements in the heap. Write a program that takes n elements as input and inserts them into a binary tree. Include a function to print out the elements in the tree.arrow_forwardSuppose we generalize the “cut rule” (in the implementation of decrease-key operation for a Fibonacci heap) to cut a node x from its parent as soon as it loses its kth child, for some integer constant k. (The rule that we studied uses k = 2.) For what values of k can we upper bound the maximum degree of a node of an n-node Fibonacci heap with O(log n)?arrow_forward
- Write a program that inserts the numbers into an initially empty BST such that the treeproduced is equivalent to binary search tree.Insert 15 as a root node then add 1 into 15 to generate 2nd number for insertion, add 2 to the2nd number to generate 3rd number continue adding according to the level of the tree till 5thlevel. Then subtract 1 from root node to generate 7th node Continue subtracting till level of 5thlevelA. The Insert function will only take the root node and construct the entire treeB. Implement a remove function which can remove the 3rd layer numbers from right andleft both sub trees.C. Implement a function to find the number which is nearby to your given age.arrow_forwardWhat is the key difference between a binary tree search and a min heap search? Is it possible, in the amount of time provided by O(n), to construct a list of keys for a binary tree that has been sorted in ascending order? How long does it take to make a list of all of the sorted keys in a heap that has been arranged in order?arrow_forwarda) i. With your own understanding, explain the Mid-Square method of generating Pseudo–Random Numbers and with your understanding in the explanation, generate 5 Pseudo–Random Numbers from the seed number 2714 . b) Use the linear congruential method to generate a sequence of 5 random numbers with given seed of 27, increment 43 and constant multiplier 17, modulus 100 . c) i. If an M/M/1 queue has utilization of 90%, what do you think will be the average queue length and the average response time? If the arrival rate is 100 jobs per second ii. If an M/D/1 queue has utilization of 80% do you expect its mean queue length and response time to be less, same, or greater than that of an M/M/1? Explain your answer.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education