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; and•a 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
You've reached the end of your free preview.
Want to read both pages?
- Spring '08