def DeleteHi k Hsize 1 index of last position Hi Hk overwrite element being

Def deletehi k hsize 1 index of last position hi hk

This preview shows page 2 out of 2 pages.

from a heap.def Delete(H,i):k = H.size-1 //index of last positionH[i] = H[k] // overwrite element being deleted withelement in last pos itionH.size = H.size-1 // decrement number of elementsSiftUp(H,i) // either SiftUp or SiftDown will do nothingSiftDown(H,i)In each part you are asked to give an example. Be sure to include in each part:the contents of your heap before the Delete operation is called;the index and value of the element being deleted; anda brief explanation of why the SiftUp or SiftDown is necessary in your example.(a) Give an example showing that the call to SiftUp at the next-to-last line is necessary.(b) Give an example showing that the call to SiftDown at the last line is necessary.7. [4 points] Solve the following divide-and-conquer recurrence equation. Express your answer using Θ(Theta) notation.T(n)=27T(n3)+n3log4n,ifn >1T(1)=1-2-Form 2B
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture