Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MULTIPLE CHOICE: Question 1: Determine the order of grown of the runtime of a function that takes an array as input based on the following

MULTIPLE CHOICE:

Question 1: Determine the order of grown of the runtime of a function that takes an array as input based on the following experimental data:

array size time
1000 3.142
2000 12.559
3000 28.281
4000 50.269

a) cubic

b) constant

c) quadratic

d) linear

Question 2: What is the running time for the following function with respect to the size of the input array?

public int f(int[] array) { int mid = array.length / 2; int count = 0; for(int i = 0; i < mid; i++) { for(int j = mid; j < array.length; j++) { if (array[i] == array[j]) count++; } } for(int k = 0; k < array.length; k++) array[k] = -array[k]; return count; } 

a) linear

b) cubic

c) quadratic

d) linearithmic

Question 3: What is the running time for the following function with respect to the size of the input array?

public int f(int[] array) { int mid = array.length / 2; int count = 0; for(int i = 0; A.length; i++) { for(int j = i; j > 0; j /= 2) { array[i] += array[j] } } } 

a) linearithmic

b) logarithmic

c) linear

d) quadratic

Question 4: You have determined that the running time of a particular algorithm has cubic order of growth with respect to the size of the input. You have run the algorithm 3 separate times on an array of size 1,000 and found that the median running time was 21.7 seconds. Which of the expressions below is the best tilde approximation for the running time of the algorithm?

a) ~0.0000000217 * n3

b) ~0.0000217 * n3

c) ~0.0217 * n3

d) ~0.0000217 * n2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

How did you feel about taking piano lessons as a child? (general)

Answered: 1 week ago