Reference no: EM13332686
Part 1 - Ulam
Given the following function:
public static int Ulam(int num)
{
if (num < 2)
return 1;
else
{
if (num % 2 == 0)
return Ulam(num/2);
else
return Ulam(3*num + 1);
}
}
1) What problems come up in verifying this function?
2) How many recursive calls are made by the following initial calls?
a. Ulam(22);
b. Ulam(16);
c. UIam(46);
Part 2 - Bubblesort
Consider your textbook's implementation of bubblesort from chapter 8. The method is included below for your convenience.
3) What is the time complexity of running the below bubblesort on an array of random integers?
4) What is the time complexity of running the below bubblesort on an array of sequential integers (1,2,3,4,5,..)?
5) Show a simple modification that can be made to the below bubblesort that significantly improves the time complexity for an array of sequential integers.
6) What is the new time complexity in the array of sequential integer's condition? Explain why this modification improved the run-time.
Part 3 - Quicksort
Consider your textbook's implementation of quicksort from chapter 8. The corrected findPartition method is included below for your convenience.
7) What is the time complexity of running quicksort using this partition method on an array of random integers?
8) What is the time complexity of running quicksort using this partition method on an array of sequential integers (1,2,3,4,5,..)?
9) Robert Sedgewick suggests using the median of the first, last and middle elements as the partition element. Explain why this modification is important.
10) Show what modifications are needed to convert the findPartition method to use the median element as the partition.
Compute the companys net sales for the year
: Compute the company’s net sales for the year. Compute the company’s total cost of merchandise purchased for the year. Prepare a multiple-step income statement that includes separate categories for selling expenses and for general and administrative e..
|
Advantage of the presidential election campaign
: Take advantage of the presidential election campaign check-off. John is an accountant. Other relevant information includes
|
Explain the reaction of 2,4-hexadiene
: Give the major product(s) (there are three of them) of the reaction of 2,4-hexadiene with Cl2(low concentration). 1-chloro-2,4-hexadiene is one of the products
|
Circumstances under which global investments
: The appropiate discount rate of the projects is 10 percent. Global Investments chose to undertake project A. At a luncheon for shareholders, the manager of a pension fund that owns a substantial amount of the firm's stock asks you why the firm chose ..
|
What is the new time complexity in the array
: What is the time complexity of running the below bubblesort on an array of random integers?
|
Determine the stress in the post
: A vertical solid steel post of diameter d = 23.1cm and length L = 2.36m is required to support a load of mass m = 8260kg. What is the stress in the post
|
Compute the molar concentration of mg2+ in the tap water
: A 200.0-mL sample of the same tap water required 47.86 mL of the standard EDTA for titration at pH 10 using calmagite indicator. Calculate the molar concentration of Mg2+ in the tap water
|
Explain the ionization constant for hcio after addition
: Calculate the pH for each of the following cases in the titration of 50.0 mL of 0.100 M HCLO with 0.100 M KOH. The ionization constant for HCIO is 4.0 x 10^-8 a) after addition of 50.0 ml of KOH
|
What is the players speed
: A 70.5kg football player is gliding across very smooth ice at 1.75 m/s. What is the player's speed afterward if the ball is thrown at 12.5m/s relative to the player
|