Given a min-priority queue A[1..7] = , consider calling Heap- Decrease-Key(A, 5, 1). Note that index...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given a min-priority queue A[1..7] = <2, 4, 3, 5, 7, 8, 6>, consider calling Heap- Decrease-Key(A, 5, 1). Note that index starts from 1. HEAP-DECREASE-KEY(A, i, k) 1 if k > A[i] 2 3 A[i] = k 4 while i>1 and A[PARENT(i)]> A[i] 5 6 error "new key is greater than current key" 2, 4, 3, 5, 1, 8, 6 1, 2, 3, 4, 7, 8, 6 1, 2, 3, 4, 5, 6, 8 1, 2, 3, 5, 4, 8, 6 swap A[i] with A[PARENT(i)] i = PARENT(i) What will be the resulting min-priority queue A? Given a min-priority queue A[1..7] = <2, 4, 3, 5, 7, 8, 6>, consider calling Heap- Decrease-Key(A, 5, 1). Note that index starts from 1. HEAP-DECREASE-KEY(A, i, k) 1 if k > A[i] 2 3 A[i] = k 4 while i>1 and A[PARENT(i)]> A[i] 5 6 error "new key is greater than current key" 2, 4, 3, 5, 1, 8, 6 1, 2, 3, 4, 7, 8, 6 1, 2, 3, 4, 5, 6, 8 1, 2, 3, 5, 4, 8, 6 swap A[i] with A[PARENT(i)] i = PARENT(i) What will be the resulting min-priority queue A?
Expert Answer:
Answer rating: 100% (QA)
Lets go through the steps of Heap DecreaseKeyA 5 1 usin... View the full answer
Related Book For
Algebra Graduate Texts In Mathematics 73
ISBN: 9780387905181
8th Edition
Authors: Thomas W. Hungerford
Posted Date:
Students also viewed these programming questions
-
A student adds NBS to a solution of 1-methylcyclohexene and irradiates the mixture with a sunlamp until all the NBS has reacted. After a careful distillation, the product mixture contains two major...
-
Graphic Design Inc. purchased a state-of-the-art laser engraving machine for $65,200. Graphic Design determined that the system had an expected life of 10 years (or 1,500,000 items engraved) and an...
-
Debit Doctors, Inc., provides accounting advice over the Internet. In recent years the company has experienced severe financial difficulty. Its accountant prepares adjusting entries on a monthly...
-
For the models shown below, determine whether it is a linear model, an intrinsically linear model, or a nonlinear model. If the model is intrinsically linear, show how it can be linearized by a...
-
In Figure, we must apply a force of magnitude 80 N to hold the block stationary at x = 2.0 cm. From that position, we then slowly move the block so that our force does + 4.0 J of work on the...
-
Carmen Camry operates a consulting firm called Help Today, which began operations on December 1. On December 31, the company's records show the following selected accounts and amounts for the month...
-
The trial balance for Yazici Advertising A.S. is shown in Illustration 3-3 (page 105). Instead of the adjusting entries shown in the text at October 31, assume the following adjustment data. 1....
-
Deuterium is an isotope of hydrogen, sometimes called heavy hydrogen. Hydrogen (H) has 1 electron, 1 proton, and 0 neutrons when neutral. Deuterium (D) has 1 electron, 1 proton, and 1 neutron when...
-
The underlying circumstances of this lawsuit are set forth in a December 6, 2005 Order denying defendant Jacqueline Tubbs motion for summary judgment. Plaintiff Estate alleges its decedent Keith...
-
Shield wires located above the phase conductors protect the phase conductors against lightning. (a) True (b) False
-
Must a lease for an apartment be in writing to be enforceable? Why?
-
The issues presented are: (1) whether the subrogation agreement between defendant fund and plaintiff Yerkovich entitled the fund to reimbursement from plaintiff for medical expenses and, if so, (2)...
-
A salesman tells you that the diamond ring you want to purchase is the best quality diamond he has in the entire store and, in fact, is the best diamond he has ever seen. After you buy the diamond,...
-
Q 10. Determine the general solution U = U(x, y) of Uyy + xUy = 0
-
You purchase a bond with a coupon rate of 6.7 percent, a par value $1,000, and a clean price of $905. Assume a par value of $1,000. If the next semiannual coupon payment is due in two months, what is...
-
Let : A B be an R-module homomorphism. (a) is a monomorphism if and only if for every pair of R-module homomorphisms g,h: D A such that g = h, we have g = h. (b) is an epimorphism if and only if...
-
For all cardinal numbers , , (a) + = + and = (commutative laws). (b) ( + ) + = + ( + ) and ( = () (associative laws). (c) ( + ) = + and ( + = , + { (distributive laws). (d) + 0 = and l...
-
If a normal subgroup N of order p (p prime) is contained in a group G of order p n , then N is in the center of G.
-
A change in chromosome structure that does not involve a change in the total amount of genetic material is a. a deletion. b. a duplication. c. an inversion. d. none of the above.
-
The term endopolyploidy refers to the phenomenon of having a. too many chromosomes. b. extra chromosomes inside the cell nucleus. c. extra sets of chromosomes in certain cells of the body. d. extra...
-
Which of the following is a type of plasmid? a. F factor (fertility factor) b. R factor (resistance plasmid) c. Virulence plasmids d. All of the above are types of plasmids.
Physics For Scientists And Engineers With Modern Physics 1st Edition - ISBN: ?0558876544 - Free Book
Study smarter with the SolutionInn App