What is the new time complexity in the array

Assignment Help Data Structure & Algorithms
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.

Reference no: EM13332686

Questions Cloud

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

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Create algorithm which will prompt for-accept four numbers

Create an algorithm which will prompt for and accept four numbers, sort them into ascending sequence and display them to the screen. Your algorithm is to include a module

  Find out the big-o running time of bubble sort

Find out the big-O running time (tight bound) of bubble sort. Illustrtae your derivation. Count comparisons as critical operation.

  Running time analyses of all the methods

You need to give the running time analyses of all the methods in terms of the Big O notation. Include your running time analyses in the source file of the CompressedSuffixTrie class and comment out them.

  Explain solution to recurrence-appealing to recursion tree

Solve the following recurrence relations by the method of your choiceT(n) = 1 for n = 4 and T(n) =pnT(pn) + n for n > 4. Argue that the solution to the recurrence T(n) = T(n=3) + T(2n=3) + cn is (n lg n) by appealing to the recursion tree.

  Sharing a large computer file

Assume you are sitting at desk at office and using your laptop computer. The boss calls an emergency meeting for you and many colleagues, and asks everyone to bring his or her laptop computer.

  Explain feasibility analysis for jobs of lrt algorithm

Study feasibility analysis for jobs of LRT algorithm when preemption is allowed. Which scheduling algorithm is best suited for high speed networks and why? Distinguish between static and dynamic systems.

  Devise algorithm to generate access control matrix

Devise an algorithm that generates an access control matrix A for any given history matrix H of the Chinese Wall model. A significant portion of the grade for this problem involves your justification of your algorithm.

  Using pseudocode, design an algorithm

BuzzButtons is a novelty item company manufacturing personalized lapel buttons. The owner is promoting his buttons by offering them at 99 cents each. He wants you to design a program asking the user for his or her name for the button, an e-mail addre..

  Creating villian

Announce a new Villian called sharpay who has a wit of 24, a stealth of sixteen, and who has currently claimed three victims: Chad, Troy, and Gabriella.

  Encryption feistel cipher and decryption algorithm

If this is psudocode for encryption feistel cipher determine decryption algorithm?Output: ciphertext = (left[16], right[16]) Explain pseudo-code of corresponding decryption algorithm for this cipher.

  Creating an access database

PLUS is a corporation that makes all types of visual aids for judicial proceedings. Customers are usually private law firms, although the District Attorney's office has occasionally contracted for its services.

  Creating an effective physical design

Class, do IT database designers necessary to understand data volumes and number of users of database in order to create an effective physical design?

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