Reference no: EM131016485
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 is cf0 in dollars
: The cost of capital to the Irish firm for a domestic project of this risk is 8%. The U.S. risk-free rate is 3%; the Irish risk-free rate is 2%. What is CF0 in dollars?
|
How do you solve system of linear equations by substitution
: How do you solve a system of linear equations by substitution? How do you solve a system of linear equations by elimination? Give an example of each method.
|
What is the difference between general and cultural
: What is the difference between general, cultural, and cross-cultural psychology
|
Write a memo outlining a policy
: You will write a memo outlining a policy regarding which rental car vendors to use for the hypothetical company you work for. Support with a graph (use graphing program) and explain your reasoning.
|
Determine a formula that counts the numbers of nodes
: 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?
|
How many times will the bell be struck in two days
: If clock strikes once at one o clock, twice at two o clock, and twelve times at twelve o clock, and again one at one o clock and so on. How Many times will the bell be struck in 2 days.
|
Explain how non-volatile ram can help speed up disk writes
: Since indexes speed up searches, why wouldn't the DBMS automatically create an index for every column of a table?
|
Social media and marketing technology in an essay
: In this assignment, you will explore social media and marketing technology in an essay. In your essay, choose a brand (or product) that relies heavily on social media or technology to market their product. Examples would be Netflix, Uber, or Coca-..
|
Calculate the volume of a slant cylinder
: Write a set of functions that calculate the volume of a slant cylinder (actually a prism) with an irregular pentagonal cross section - Write a function named polyvol to solve this.
|