Algorithms 1 - M3

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

9

Numerical Answer. Consider the function: f(n)=50n The smallest value for n0 such that ∀ n≥ n0 0 ≤ f(n) ≤ 2^n is _________________.

11

Provide a numerical answer. Consider this snapshot of an algorithm: a = 0 for i = 1 to 10 a = a + 1 The for-loop instruction will execute _______ comparisons. Do not count operations inside the body of the for-loop.

k.T(n) where 0< k < 1

Select the best answer. An algorithm A implemented and compiled on a machine M has an execution time T(n). Suppose that the machine M is equipped with a new CPU that runs with a frequency twice the original frequency. Then the algorithm A will have on the modified machine an executing time _________________. None of these answers (T(n))^2 2.T(n) k.T(n) where 0< k < 1 k.T(n) where k > 1

k.T(n) where k > 1

Select the best answer. An algorithm A implemented and compiled on a machine M1 has a execution time T(n). Suppose that the algorithm A is compiled for a machine M2 that produces en average twice the number of machine instructions per pseudocode instruction. Keeping everything else the same as Machine M1, then the algorithm A will have on the machine M2 an execution time _________________. 4.T(n) k.T(n) where 0< k < 1 (T(n))^4 None of these answers k.T(n) where k > 1

k.T(n) where 0< k < 1

Select the best answer. An algorithm A implemented and compiled on a machine M1 has a execution time T(n). Suppose that the algorithm A is compiled with a different compiler that produces en average half the number of machine instructions per pseudocode instruction. Then the algorithm A compiled with the new compiler will have an execution time _________________. (T(n))^2 k.T(n) where k > 1 k.T(n) where 0< k < 1 2.T(n) None of these answers

[] g(n) = n^2+lg(n)

Select the best answer. Consider the function f(n)=3n^2+2lg⁡(n) Check the best upper bound g(n) such that f(n)∈O(g(n)) [] g(n) = n^2+lg(n) [] g(n) = 3n^2 [] None of these answers [] g(n) =2lg(n) [] g(n) =n^3

None of these answers

Select the best answer. Consider the function f(n)=n^n Check the best upper bound g(n) such that f(n)∈O(g(n)) g(n) =10^n g(n) = 2^n None of these answers g(n) = n! g(n) =e^n

2

Two algorithms A1 and A2 solve the same problem. The running times of algorithms A1 and A2 are T1(n) and T2(n), respectively. T1(n)= sq.rt(n) + lg⁡(n) T2(n)= lg⁡(n) Four students make the following statements: Student 1: T1(n)∈O(T2(n)) Student 2: T1(n)∈Ω(T2(n)) Student 3: T1(n)∈Θ(T2(n)) Student 4: Algorithm A1 is better than Algorithm A2 List the students who made true statements.

1, 4

Two algorithms A1 and A2 solve the same problem. The running times of algorithms A1 and A2 are T1(n) and T2(n), respectively. T1(n)= sq.rt(n) + lg⁡(n) T2(n)= n Four students make the following statements: Student 1: T1(n)∈O(T2(n)) Student 2: T1(n)∈Ω(T2(n)) Student 3: T1(n)∈Θ(T2(n)) Student 4: Algorithm A1 is better than Algorithm A2 Check the students who made true statements.

1,2,3,4

Two algorithms A1 and A2 solve the same problem. The running times of algorithms A1 and A2 are T1(n) and T2(n), respectively. T1(n)=0.3*n^2 + 0.1n*lg(n) T2(n)=45n^2 Four students make the following statements: Student 1: T1(n)∈O(T2(n)) Student 2: T1(n)∈Ω(T2(n)) Student 3: T1(n)∈Θ(T2(n)) Student 4: Algorithm A1 is better than Algorithm A2 Check the students who made true statements.

[] CPU instruction set [] the CPU [] the operating system [] The number of machine [] instruction per pseudo code im [] Clock frequency

check all that apply. The efficiency of an algorithm should be evaluated/characterized independently from: [] CPU instruction set [] input size [] the CPU [] the operating system [] The number of machine [] instruction per pseudo code im [] Clock frequency

1. 5000lg(n) 1. ln(n) 2. 1000nlg(n) 3. 0.001n^(1+0.1) 4. 0.0001n^2

A function f(n) is of higher order than g(n) if f(n)∈Ω(g(n)) In other words, f(n) is of higher order than g(n) if g(n) is an asymptotic lower bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. 0.0001n^2 5000lg(n) ln(n) 0.001n^(1+0.1) 1000nlg(n)

1. 10000000lg(n) 2. n 3. 4n^4 + 1000 n^2 + 2 3. 1000n^4 + 4n^2 + 1 3. n^4

A function f(n) is of higher order than g(n) if f(n)∈Ω(g(n)) In other words, f(n) is of higher order than g(n) if g(n) is an asymptotic lower bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. 4n^4 + 1000 n^2 + 2 1000n^4 + 4n^2 + 1 n^4 10000000lg(n) n

1. 5000000lg(lg(n)) 2. 5000 lg(n) 3. lg^2(n) 4. 10 Square Root (n) 5. 0.001n

A function f(n) is of higher order than g(n) if f(n)∈Ω(g(n)) In other words, f(n) is of higher order than g(n) if g(n) is an asymptotic lower bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. 5000000lg(lg(n)) 5000 lg(n) 10 Square Root (n) 0.001n lg^2(n)

1. 1000lg^2(n) 2. Square Root (n) 3. 2^(n-1) 3. 2^n 4. n!

A function f(n) is of higher order than g(n) if f(n)∈Ω(g(n)) In other words, f(n) is of higher order than g(n) if g(n) is an asymptotic lower bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. n! 2^(n-1) Square Root (n) 1000lg^2(n) 2^n

1. 1,000,000 2. 1000lg(n) 3. Square Root (n) 4. n^2 + lg(n) 4. n^2

A function f(n) is of higher order than g(n) if f(n)∈Ω(g(n)) In other words, f(n) is of higher order than g(n) if g(n) is an asymptotic lower bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. n^2 + lg(n) n^2 Square Root (n) 1000lg(n) 1,000,000

1. 1,000,000 2. 1000lg(n) 3. Square Root (n) 4. n^2 + lg(n) 4. n^2

A function f(n) is of higher order than g(n) if f(n)∈Ω(g(n)) In other words, f(n) is of higher order than g(n) if g(n) is an asymptotic lower bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. n^2 + lg(n) n^2 Square Root (n) 1000lg(n) 1,000,000

1. 5000000lg(lg(n)) 2. 5000lg(n) 3. 10Square Root (n) 4. nlg(n) 5. 0.001n^(1+0.1)

A function f(n) is of lower order than g(n) if f(n)∈O(g(n)) In other words, f(n) is of lower order than g(n) if g(n) is an asymptotic upper bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. 5000000lg(lg(n)) 5000lg(n) 10Square Root (n) 0.001n^(1+0.1) nlg(n)

1. 1000lg(n)^2 2. Square Root (n) 3. 2^(n-1) 3. 2^n 4. n!

A function f(n) is of lower order than g(n) if f(n)∈O(g(n)) In other words, f(n) is of lower order than g(n) if g(n) is an asymptotic upper bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. n! 2^(n-1) Square Root (n) 1000lg(n)^2 2^n

1. 1000lg(n)^2 2. Square Root (n) 3. 2^(n-1) 3. 2^n 4. n!

A function f(n) is of lower order than g(n) if f(n)∈O(g(n)) In other words, f(n) is of lower order than g(n) if g(n) is an asymptotic upper bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. (list top (1) to bottom (5) with same number on same line) n! 2^(n-1) Square Root (n) 1000lg(n)^2 2^n

1. 5000000 lg( lg(n)) 2. 5000 lg(n) 3. lg(n)^2 4. 10 Square Root (n) 5. 0.001 n

A function f(n) is of lower order than g(n) if f(n)∈O(g(n)) In other words, f(n) is of lower order than g(n) if g(n) is an asymptotic upper bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. 5000000 lg( lg(n)) 5000 lg(n) 10 Square Root (n) 0.001 n lg(n)^2

1. 5000000 lg( lg(n)) 2. 5000 lg(n) 3. 10 Square Root (n) 4. n lg(n) 5. 0.001 n^(1+0.1)

A function f(n) is of lower order than g(n) if f(n)∈O(g(n)) In other words, f(n) is of lower order than g(n) if g(n) is an asymptotic upper bound to f(n). Match the following functions based on their order. Assign the number 1 to the function with the lowest order. Assign the same number to functions with the same order. 5000000lg(lg(n)) 5000lg(n) 10Square Root (n) 0.001n^(1+0.1) nlg(n)

k.T(n) where k > 1

An algorithm A implemented and compiled on a machine M1 has a execution time T(n). Suppose that the algorithm A is compiled for a machine M2 that produces en average twice the number of machine instructions per pseudocode instruction. Keeping everything else the same as Machine M1, then the algorithm A will have on the machine M2 an execution time _________________. (T(n))^4 k.T(n) where 0< k < 1 None of these answers k.T(n) where k > 1 4.T(n)

None of these answers

An algorithm A implemented and compiled on a machine M1 has a execution time T(n). Suppose that the algorithm A is compiled with a different compiler twice faster than the original compiler. Then the algorithm A compiled with the new compiler will have an execution time _________________. (T(n))^2 k.T(n) where k > 1 k.T(n) where 0< k < 1 2.T(n) None of these answers

T(n^2)

An algorithm A implemented and compiled on a machine M1 has an execution time T(n). The running (execution) time for an input of size n2 will be __________. T(n) (T(n))^2 None of these answers 2.T(n) where k = 2 T(n^2)

[] the input size [] The total number of pseudocode instructions executed by the algorithm the CPU [] the clock frequency [] the number of clock cycles per pseudo [] the instruction set

Check all that apply. The running (execution) time of an algorithm depends on: [] the input size [] The total number of pseudocode instructions executed by the algorithm the CPU [] the clock frequency [] the number of clock cycles per pseudo [] the instruction set

g(n) = n! g(n) = 1.01^n g(n) = n^2 g(n) = n^k with k >= 1

Check all that apply. Consider the function f(n)=1000n+2000 Check all functions g(n) such that f(n)∈O(g(n)) g(n) = n! g(n) = 1.01^n g(n) = n^k with k >= 0 g(n) = n^2 g(n) = n^k with k >= 1 g(n) = 1,000,000 lg(n)

g(n) = 1.01^n g(n) = n! g(n) = n^k with k >= 3

Check all that apply. Consider the function f(n)=2n^3+1000 Check all functions g(n) such that f(n)∈O(g(n)) g(n) = 1,000,000 n^2 g(n) = n^k with k >= 1 g(n) = 1.01^n g(n) = n! g(n) = n^k with k >= 3 g(n) = n^2

[] CPU [] compiler [] instruction set

Check all that apply. The number of machines instructions per pseudocode instruction depends on: [] clock frequency [] CPU [] input size [] operating system [] compiler [] instruction set

g(n) = ln(n)

Consider the function f(n)= ln⁡(2) lg⁡(n) Check the best upper bound g(n) such that f(n)∈O(g(n)) g(n) = lg(n)^2 g(n) =lg(lg(n)) None of these answers g(n) = square root(n) g(n) = ln(n)

g(n) = lg^10(n) g(n) = 1,000,000n^4

Consider the function f(n)=1000n^5+1000 Check all functions g(n) such that f(n)∈Ω(g(n)) g(n) = n^k with k >= 5 g(n) = 2^n g(n) = 1.0001^n g(n) = lg^10(n) g(n) = n! g(n) = 1,000,000n^4

g(n) = 2^(n+1)

Consider the function f(n)=2^n Check the best lower bound g(n) such that f(n)∈Ω(g(n)) g(n) = 3^n None of these answers g(n) =n! g(n) = 2.001^n g(n) = 2^(n+1)

g(n) = 2^(n-1)

Consider the function f(n)=2^n Check the best upper bound g(n) such that f(n)∈O(g(n)) None of these answers g(n) = 3^n g(n) = 2^(n-1) g(n) =n! g(n) = 2.001^n

g(n) = e^n where e is the Euler number g(n) = 1.5^(2n) g(n) = 2^n g(n) = k^n with k >= 2 g(n) = n!

Consider the function f(n)=2^n+1,000,000 Check all functions g(n) such that f(n)∈O(g(n)) g(n) = lg(n)^1000 g(n) = n^k with k >= 1000 g(n) = e^n where e is the Euler number g(n) = 1.5^(2n) g(n) = 2^n g(n) = k^n with k >= 2 g(n) = n!

g(n) = n^2 g(n) = n^k with k <=3 g(n) = 1,000,000 n^2

Consider the function f(n)=2n^3+1000 Check all functions g(n) such that f(n)∈Ω(g(n)) g(n) = n! g(n) = n^2 g(n) = n^k with k <=3 g(n) = n^k with k >= 3 g(n) = 1,000,000 n^2 g(n) = 1.01^n

g(n) = n^2+lg(n)

Consider the function f(n)=3n^2+2 lg⁡(n) Check the best upper bound g(n) such that f(n)∈O(g(n)) g(n) =n^3 g(n) =2lg(n) None of these answers g(n) = n^2+lg(n) g(n) = 3n^2

g(n) = n^n

Consider the function f(n)=n! Check the best upper bound g(n) such that f(n)∈O(g(n)) g(n) = 2^n g(n) =e^n g(n) =10^n g(n) = n^n None of these answers

317

Consider the function: f(n)=100,000n The smallest value for n0 such that ∀n≥n0 0 ≤ f(n) ≤ n^3 is _________________.

10

Consider the function: f(n)=10n^2 The smallest value for n0 such that ∀n ≥ n0 0 ≤ f(n) ≤ n^3 is _________________.

8

Consider the function: f(n)=20n The smallest value for n0 such that ∀n ≥ n0 0 ≤ f(n) ≤ 2^n is _________________.

13

Consider the function: f(n)=50n−625 The smallest value for n0 such that ∀ n ≥ n0 0 ≤ f(n) ≤ n^2 is _________________.

3

Consider this algorithm: a = 0 for i = 0 to n-1 for j = i+1 to n-1 a = a + 1 The objective is to count the total number T(n) of additions performed by the statement a = a + 1. Four students evaluate T(n) and found these expressions: Student 1: n−1 ∑ 1 i=0 Student 2: n−1 ∑ 1 j=i+1 Student 3: n−1 n−1 ∑ ∑ 1 i=0 j=i+1 Student 4: n−1 n−1 ∑ ∑ j i=0 j=i+1 The expression of Student __ is right.

4

Consider this algorithm: a = 0 for i = 0 to n-1 for j = i+1 to n-1 a = a + 1 The objective is to count the total number T(n) of additions performed by the statement a = a + 1. Four students evaluate T(n) and found these expressions: Student 1: n−1 Student 2: n−i−1 Student 3: 1/2(n^3−n) Student 4:1/2(n^2−n) Student __________'s expression is right.

1, 2, 3

Consider this algorithm: a = 0 for i = 0 to n-1 for j = i+1 to n-1 a = a + 1 The total number T(n) of additions performed by the statement a = a + 1 is (1/2)(n^2−n). Four students propose different bounds: Student 1: O(n^3) Student 2: Θ(n^2) Student 3: Ω(n^2) Student 4: Ω(1/2*n^3) Which students were correct?

2

Consider this algorithm: a = 0 for i = 0 to n-1 for j = i+1 to n-1 a = a + 1 The total number T(n) of additions performed by the statement a = a + 1 is 1/2(n^2−n). Four students proposent different bounds: Student 1: O(n^2) Student 2: Θ(n^2) Student 3: Ω(n^2) Student 4: Ω(1/2*n^2) The best bound characterization is Student __________'s bound

1, 2, 3

Consider this algorithm: a = 0 for i = 0 to n-1 for j = i+1 to n-1 a = a + 1 The total number T(n) of additions performed by the statement a = a + 1 is 1/2(n^2−n). Four students proposent different bounds: Student 1: O(n^3) Student 2: Θ(n^2) Student 3: Ω(n^2) Student 4: Ω(1/2*n^3) Check all valid bounds.

12

Consider this snapshot of an algorithm: a = 0 for i = 0 to 10 a = a + 1 Overall, this algorithm will perform _______ comparisons.

10

Consider this snapshot of an algorithm: a = 0 for i = 1 to 10 a = a + 1 The for-loop instruction will execute _______ additions. Do not count operations inside the body of the for-loop.

2

Consider this snapshot of an algorithm: for i = 1 to 9 a = 0 for j = i+1 to 10 a = a + 1 The inner for-loop instruction will execute _______ comparisons when i = 9. Do not count operations inside the body of the for-loop.

2

Consider this snapshot of an algorithm: for i = 1 to n-1 a = 0 for j = i+1 to n a = a + 1 The inner for-loop instruction will execute _______ comparisons when i = n-1. Do not count operations inside the body of the for-loop.

1

Consider this snapshot of an algorithm: for i = 1 to n-1 a = 0 for j = i+1 to n a = a + 1 The inner for-loop instruction will execute the statement a = a+1 _______ times when i = n-1.

22

Consider this snapshot of an algorithm: a = 0 for i = 0 to 10 a = a + 1 Overall, this algorithm will perform _______ additions.

n-1

Fill in the blank. Consider this snapshot of an algorithm: for i = 1 to n-1 a = 0 for j = i+1 to n a = a + 1 The inner for-loop instruction will execute _______ comparisons when i = 2. Do not count operations inside the body of the for-loop.

n-1

Fill in the blank. Consider this snapshot of an algorithm: for i = 1 to n-1 a = 0 for j = i+1 to n a = a + 1 The inner for-loop instruction will execute the statement a = a+1 _______ times when i = 1.

1,2,3,4

Two algorithms A1 and A2 solve the same problem. The running times of algorithms A1 and A2 are T1(n) and T2(n), respectively. T1(n)= 3/2*n^2 + 7n − 4 T2(n)= 8n^2 Four students make the following statements: Student 1: T1(n)∈O(T2(n)) Student 2: T1(n)∈Ω(T2(n)) Student 3: T1(n)∈Θ(T2(n)) Student 4: Algorithm A1 is better than Algorithm A2 Check the students who made true statements.

2

Two algorithms A1 and A2 solve the same problem. The running times of algorithms A1 and A2 are T1(n) and T2(n), respectively. T1(n)= sq.rt(n) + lg⁡(n) T2(n)= 1 Four students make the following statements: Student 1: T1(n)∈O(T2(n)) Student 2: T1(n)∈Ω(T2(n)) Student 3: T1(n)∈Θ(T2(n)) Student 4: Algorithm A1 is better than Algorithm A2 Check the students who made true statements.

2

Two algorithms A1 and A2 solve the same problem. The running times of algorithms A1 and A2 are T1(n) and T2(n), respectively. T1(n)= sq.rt(n) + lg⁡(n) T2(n)= lg⁡(n) Four students make the following statements: Student 1: T1(n)∈O(T2(n)) Student 2: T1(n)∈Ω(T2(n)) Student 3: T1(n)∈Θ(T2(n)) Student 4: Algorithm A1 is better than Algorithm A2 Check the students who made true statements.

1, 4

Two algorithms A1 and A2 solve the same problem. The running times of algorithms A1 and A2 are T1(n) and T2(n), respectively. T1(n)= 10*sq.rt(n) + lg⁡(n) T2(n)=n Four students make the following statements: Student 1: T1(n)∈O(T2(n)) Student 2: T1(n)∈Ω(T2(n)) Student 3: T1(n)∈Θ(T2(n)) Student 4: Algorithm A1 is better than Algorithm A2 Check the students who made true statements.


Ensembles d'études connexes

Macroeconomics: Week 8 Assessment

View Set

RNA, Transcription, and Translation Notes - Biology

View Set

Chapter 3: Savings and Investment

View Set

Block 3 - Lesson 3 - Shear Turbulence

View Set