Write the recurrence equation and initial conditions that


For problems 1 and 2, consider the following functions that implement the dequeue operation for a priority queue that is implemented with a heap.

int[] pQueue;

int length;

int dequeue()

{

int node = 1;

int value = pQueue[--length];

int maxValue = pQueue[node];

int location = sift(node * 2, value);

pQueue[location] = value;

return maxValue;

}

int sift(int node, int value)

{

if (node <= length)

{

if (node < length && pQueue[node] < pQueue[node + 1]) node++;

if (value < pQueue[node])

{

pQueue[node / 2] = pQueue[node];

return sift(node * 2, value);

}

}

return node / 2;

}

1. Write the recurrence equation and initial conditions that expresses the execution time cost for the sift function in the above algorithm. Draw the recursion tree assuming that n = 8. Assume that n represents the number of nodes in the subtree at each step of the sifting operation.

2. Determine the critical exponent for the recurrence equation in problem 1. Apply the Little Master Theorem to solve that equation specifically stating which part of the theorem is applied to arrive at the solution.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write the recurrence equation and initial conditions that
Reference No:- TGS02899641

Expected delivery within 24 Hours