Determine a formula that counts the numbers of nodes

Assignment Help Basic Computer Science
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.

Reference no: EM131016485

Questions Cloud

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.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd