Question

CAN YOU PLEASE ANSWER ALL THESE QUSTIONS 1.In Merge sort, how many additional recursive partitioning levels...

CAN YOU PLEASE ANSWER ALL THESE QUSTIONS

1.In Merge sort, how many additional recursive partitioning levels are required for a list of 64 elements compared to a list of 8 elements?

a.

3

b.

9

c.

8

d.

6

2. Which function best represents the number of operations in the worst-case for the following code fragment?

for (i = 0; i < N; ++i) {

   if (numbers[i] % 2 == 1)

      factor = 2.5

}

a.

f(N) = 6N2

b.

f(N) = 5N + 2

c.

f(N) = 2N

d.

f(N) = 8N2 + 4

3. The list 76, 56, 93, 24, 45, 88, 13, 7, 37 is sorted using bucket sort with 4 buckets. Which bucket will contain 45?

a.

1

b.

0

c.

3

d.

2

4. When sorting with bubble sort, how many swaps are needed for 98 to reach its sorted position in the list 98, 12, 34, 78, 35, 78, 45?

a.

4

b.

6

c.

5

d.

7

Homework Answers

Answer #1

Solution

1)the partition levels can be calculated by the following formula

So for 8 elements

Partition levels =3

For 64 elements

Partition levels =6

So we need 3 extra Recursive partition levels

2)the worst case is f(N) =8N2+4

3)the element 45 will be in second bucket (since the distribution of elements will be as M/n, where M is total number of elements and n is total number of buckets)

4) we need 6 swaps to put 97 in its sorted position

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
out of the following four: 1.Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort a. Which...
out of the following four: 1.Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort a. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is random? b. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is 90% sorted? c. Which sorting methods perform best and worst for data sizes ≥ 25,000 when the input data is reverse sorted? d. Which sorting methods perform best and...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n ==...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n == 0)    return 0; else    return n * f(n - 1); } A. 120 B. 60 C. 1 D. 0 10 points    QUESTION 2 Which of the following statements could describe the general (recursive) case of a recursive algorithm? In the following recursive function, which line(s) represent the general (recursive) case? void PrintIt(int n ) // line 1 { // line 2...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
LANGUAGE IS C++ 1- A link based getEntry method requires how many steps to access the...
LANGUAGE IS C++ 1- A link based getEntry method requires how many steps to access the nth item in the list? a)n b)n+1 c)n^2 d)n-1 2- When calling the insert or remove methods, what is an disadvantage for the link-based implementation of the ADT List? a)harder to understand b)must shift data c)searching for that position is slower d)takes more memory 3-What is the last step in the insertion process for a linked implementation of the ADT List? a)Connect the new...
please show all work and circle answer if you cant do all the parts please don't...
please show all work and circle answer if you cant do all the parts please don't answer question part 1) Let g(x,y)=cos(8x+5y). Evaluate g(1,−2). Answer: g(1,−2)= part 2) Suppose f(x,y)=xy^2−8. Compute the following values: f(4,3) = f(3,4) = f(0,0) = f(−1,3) = f(t,2t) = f(uv,u−v) = part 3) Consider the concentration, C, (in mg/liter) of a drug in the blood as a function of the amount of drug given, x, and the time since injection, t. For 0≤x≤6 mg and...
Write a code in c++ using linear insertion following the steps below. Comment your work. 1....
Write a code in c++ using linear insertion following the steps below. Comment your work. 1.    Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program. 2.     You can use a statically-allocated one-dimensional array of doubles for this with length 100. You...
Problem 1 ...... you can use Matlan i got one so all what i need is...
Problem 1 ...... you can use Matlan i got one so all what i need is 2, 3 and 4 one of them or all of them .. thanks The following Scilab code generates a 10-second “chirp” with discrete frequencies ranging from 0 to 0.2 with a sampling frequency of 8 kHz. clear; Fs = 8000; Nbits = 16; tMax = 10; N = Fs*tMax+1; f = linspace(0.0,0.2,N); x = zeros(f); phi = 0; for n=0:N-1 x(n+1) = 0.8*sin(phi); phi...
Please answer all questions if you can. Thank you in advanced! 1. Compare and contrast how...
Please answer all questions if you can. Thank you in advanced! 1. Compare and contrast how secondary structure forms in folded proteins and folded RNA molecules 2. Assume that a bacterial genome contains 5000 genes. Do a “back of the envelope” calculation to estimate the size (number of nucleotides) of the genome of this bacterium. In your answer briefly demonstrate your knowledge of genes. 3. Describe the design of the DNA sequence of an artificial chromosome in a typical eukaryote...
CAN YOU PLEASE ANSWER ALL QUESTIONS AND PLEASE ANSWER AS SOON AS POSSIBLE THANK YOU 1....
CAN YOU PLEASE ANSWER ALL QUESTIONS AND PLEASE ANSWER AS SOON AS POSSIBLE THANK YOU 1. Frequency selectivity of the basilar membrane changes when the sound intensity is changed: a. True b. False 2. Which structure is the first relay nucleus for taste? Insula Nucleus of the solitary tract Red nucleus Pineal gland 3. How does sensory information reach the amygdala? a. Through the ventral thalamus and primary-association cortices b. Through a subcortical route from the dorso-medial thalamus c. Through...
*******PLEASE EXPLAIN HOW YOU GOT THE ANSWER.******** 1.) Rank the following charge/distance combinations from lowest energy...
*******PLEASE EXPLAIN HOW YOU GOT THE ANSWER.******** 1.) Rank the following charge/distance combinations from lowest energy to highest energy. Your answer should be a four letter "word" made up of the letters a, b, c and d. For example, if you think the order is a (lowest energy), then b, then c, then d (highest energy), you should enter the "word" abcd in the answer box. Note, the word has no spaces or commas. a) A -3 charge and a...