1. Sorting algorithms are one kind of algorithm whose performance may depend upon the data. Choose one of the sorting algorithms or any other algorithm and explain whether the there are any differences in the best, average and worst cases. If there are no differences, explain why not. If there are differences, describe the data in the different cases and explain how the performance differs in each case.
 
2. Consider the following functions for problems 3 and 4.
void selectionSort(int array[])
{
sort(array, 0);
} void sort(int[] array, int i)
{
           if (i < array.length – 1)
           {
                    int j = smallest(array, i);
                    int temp = array[i];
                    array[i] = array[j];
                    array[j] = temp; sort(array, i + 1);
            }
}
int smallest(int[] array, int j)
{
        if (j == array.length – 1)
                   return array.length – 1;
        int k = smallest(array, j + 1);
        return array[j] < array[k] ? j : k;
}
3. Draw the recursion tree for selectionSort when it is called for an array of length 4. Show the activations of selectionSort, sort and smallest in the tree.
4. Determine a formula that counts the numbers of nodes in the recursion tree. What is Big- O for execution time? Determine a formula that expresses the height of the tree. What is the Big-O for memory?
 
For problems 5 and 6, 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;
}
5. 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.
6. Determine the critical exponent for the recurrence equation in problem 5. Apply the Little Master Theorem to solve that equation specifically stating which part of the theorem is applied to arrive at the solution.
 


What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but you proved you are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 11***| Rating: ⭐⭐⭐⭐⭐
"This company is the best there is. They saved me so many times, I cannot even keep count. Now I recommend it to all my friends, and none of them have complained about it. The writers here are excellent."


"Order a custom Paper on Similar Assignment at essayfount.com! No Plagiarism! Enjoy 20% Discount!"