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

  How does lossy compression help

How does lossy compression help

  Uses parallel arrays to determine the batting average

Write a program that uses parallel arrays to determine the batting average and slugging percentage for a baseball team by position.

  In mips assembly language

In MIPS Assembly language

  How to build a secure virtual network

This report is based on the concept of virtual network. Today various new technologies have been introduced to fulfill various requirements of the users. As much as technologies are developed the security issues are also increasing. Network secur..

  Create a database to store information

Assume that you want to create a database to store information about your music collection. You want to be able to query the database for each of the following attributes: • A particular title (for example, Tapestry or Beethoven's Fifth Symphony) • A..

  Creating a context diagram

Refer again to the information about the Reliable Pharmaceutical Service (RPS) at the end of Chapter 1, "The World of the Information Systems Analyst."

  Explaining anticybersquatting consumer protection act

What does Anticybersquatting Consumer Protection Act perform? How does this act cut down on nuisance suits?

  Identify and describe any potential ethical issues

Identify and describe any potential ethical issues that could arise in connection with the new architecture.

  Research financial policies that promote international trade

You have been hired as a consultant to analyze the possibilities, make a recommendation on what path to follow, and assist in transition.

  New privacy issues related to cyberspace

New Privacy Issues Related to Cyberspace

  Explaining competition in early years of telephone industry

Was regulation alternative to competition in early years of telephone industry?

  The processes and procedural considerations for implementing

For the purpose of this assignment, you will have to recap your previous assignment (in 250 words) and then provide a well-researched and informed report to the CIO.

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