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

  Define the function and module breakup

Define the Function and module breakup

  Time evolution of a closed circular string

At t = 0, a closed string forms a circle of radi us R on the (x , y) plane and has zero veloci ty. The ti me development of this string can be studied usi ng the action (6.88).

  Explain cost and scope in procurement management section

Please review the attached paper and make necessary corrections. Additionally please include triple threat items - time, cost and scope in Procurement Management section in following sections

  Defend role of it department strategic and operational

Defend the role of the IT department as both a strategic and operational asset for the company.

  Discuss advantages and disadvantages of ethernet technology

Broad-band LAN technology divides the available bandwidth of the cable system into multiple channels using a technique called

  Write a driver client that demonstrates all the features

For the extra 2 points, you might try adding an overloaded operator like subtract. Write a driver client that demonstrates all the features of your class.

  Enhance your site

Write a two- to four-page paper describing how you would change or enhance your site if you "knew then what you know now". Be sure to include interaction with Spry Validation Text Field, Spry Collapsible Panel widget, and Adobe widgets in your new..

  What are local and global variables

What are local and Global variables? And how many input variables can a MATLAB function have ?

  What are the pros and cons of each raid

Please explain how each RAID configuration works and what are the pros and cons of each RAID?

  Security principles paper

Introduction to Information Systems Security Security Principles Paper

  Develop a scanner object in main method

Assume that inside main method below you make decision to develop a Scanner object, and then read in int and then double on one line, where two values are separated by space.

  Find customer from the database based

Create a third page with a search box so that you can find customer from the database based on name. (5) Customer Example Page Name: * Phone: E-mail Address: * City: Country: How did you find us? Search Engine?Link From Another Site?News Article? ..

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