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...
1. in a ____________, you repeatedly compare pairs of items, swapping them if they are out...
1. in a ____________, you repeatedly compare pairs of items, swapping them if they are out of order, eventually creating a sorted list a. range match b. bubble sort c. enhance for loop d. float sort 2. an array that you can picture as a column of values, and whose elements you can access using one script is a _____array a. single dimensional b. two dimensional c. parallel d. column 3. how would you create an array name someNumbers that...
DIRECTIONS: IMPLEMENT QuickSort and MergeSort. You have been provided: 1. Functions to perform Merge (for MergeSort)...
DIRECTIONS: IMPLEMENT QuickSort and MergeSort. You have been provided: 1. Functions to perform Merge (for MergeSort) and Partition (for QuickSort). 2. In class we discussed the body of the recursive functions, the "brakes" needed to stop the recursion. You are expected to develop 2 RECURSIVE programs: 1. Complete the bodies of the sort functions, MergeSort and QuickSort. 2. Complate the main that tests each function. - program should not read inputs - stock the program with multiple arrays (test cases)...
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...
You can complete this assignment individually or as a group of two people. In this assignment...
You can complete this assignment individually or as a group of two people. In this assignment you will create a ​​Sorted Singly-Linked List​ that performs basic list operations using C++. This linked list should not allow duplicate elements. Elements of the list should be of type ‘ItemType’. ‘ItemType’ class should have a private integer variable with the name ‘value’. Elements in the linked list should be sorted in the ascending order according to this ‘value’ variable. You should create a...
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...
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...
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...