Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 19, Problem 3P
(a)
Program Plan Intro
To analyse the amortized running time of FIB-HEAP-CHANGE-KEY when k is greater than or equal to
(b)
Program Plan Intro
Give an efficient implementation of FIB-HEAP-PRUNE( H,r ) and also describe the amortized running time of Implementation.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Think about the challenge of finding the smallest element in a maximum heap. A max heap's smallest components must be one of the n/2 leaves. (If not, the tree cannot be a max heap since there must be a nonleaf smaller than one of its descendants.) Therefore, a thorough leaf search is sufficient. Show, at the very least, that leaf-by-leaf searching is required.
Suppose 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)?
Given a max-heap H with n elements and a value x, write the pseudocode of most efficientpossible algorithm that prints all keys in H that are greater than x (i.e., use the command print).The max-heap H should remain intact. Please indicate the worst-case running time of your algorithmand justify your answer. (Note: A procedure that always traverses the whole heap, regardless of thevalue of x and the elements in the heap, is considered an inefficient algorithm.)
Chapter 19 Solutions
Introduction to Algorithms
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Given an initial sequence of 9 integers < 53, 66, 392, 62, 32, 41, 22, 36, 26 >, answer the following:a) Construct an initial min-heap from the given initial sequence above, based on the HeapInitialization with Sink technique learned in our course. Draw this initial min-heap. NOsteps of construction are required. b) With heap sorting, a second min-heap can be reconstructed after removing the root of theinitial min-heap above. A third min-heap can then be reconstructed after removing theroot of the second min-heap. Represent these second and third min-heaps with array (list)representation in the table form below. NO steps of construction required.arrow_forwarda. Show how to implement a queue with two ordinary stacks so that the amortized cost of each Enqueue and Dequeue operation is O(1). b. Consider an ordinary min-heap supporting operations Insert and Extract-min that each costs O(lg n) worst-case time complexity when there are n items in the heap. Give a potential function Φ such that the amortized cost of Insert is O(lg n) and the amortized cost of Extract-min is O(1). Show Φ yields these amortized time bounds (n is the number of items currently in the heap and the size of the heap is unknown). Note: “Show” means to provide a proof with logical and precise arguments and/or derivations.arrow_forwardAlgorithm Demonstrate, step by step, how to construct a max-heap for the list of integers A[1..8] = (12, 8, 15, 5, 6, 14, 1, 10) (in the given order), following Example 4.14.arrow_forward
- Let's assume that a binary heap is represented using a binary tree such that each node may have a left child node and a right child node. For this type of representation, we can still label the nodes of the tree in the same way as we label the nodes for an array representation. That is, the root node has a label 1. In general, for a node with label i, its left child node will have a label 2i and the right child has a label 2i+1. For any i with 1 <= I <= n , Terry says that the following easy algorithm will walk you from the root node to the node with label i: First find the binary representation P of i. Start with the rightmost bit (least significant bit) of P, walk down from the root as follow: For a 0 bit, walk to the left child, for a 1 bit walk to the right child. At the end, you’ll reach the node with label i. Which of the following is the most appropriate? A. Terry’s algorithm is wrong and not fixable. B. Terry’s algorithm is right. C. Terry's algorithm can be…arrow_forwardwrite pseudo-code of an algorithm that finds the maximum value in a binary min-heap what is the asymptotic complexity of your algorithm? showing your work is required.arrow_forwardIs BUILD-MAX-HEAP recurrent? Why do we want the loop index i in line 2 of BUILD-MAX-HEAP to decrease from length[A]/2] to 1 rather than increase from 1 to [length[A]/2]? BUILD-MAX-HEAP(A)1 heap-size[A] ← length[A]2 for i ← [length[A]/2] downto 13 do MAX-HEAPIFY(A, i )arrow_forward
- Problem1: Use the procedure MAX-HEAPIFY in a bottom-up manner to convert the arrayA = <1, 7, 6, 8, 0, 5, 2, 12, 3, 18> to build a max heap Problem 2:Insert the following set of keys {1, 7, 6, 8, 0, 5, 2, 12, 3, 18} in an empty binary search tree in the order they are listed.arrow_forwardShow the Fibonacci heap that results from calling FIB-HEAP-EXTRACT-MIN onthe Fibonacci heaparrow_forwardSuppose we are given access to a min-heap, but not the code that supports it. What changes to the comparable data might we make to force themin-heap to work like a max-heap?arrow_forward
- 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_forwardSuppose you are given n distinct values to store in a full heap—a heap that is maintained in a full binary tree. Since there is no ordering between children in a heap, the left and right subheaps can be exchanged. How many equivalent heaps can be produced by only swapping children of a node?arrow_forwardSuppose we have to do m inserts and n deletions, starting from an empty heap. When would it be more beneficial to use a d-heap rather than a binary heap?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education