Self Study Quizzes

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Provide a numerical value. The objective of this exercise is to find the largest input size N that an algorithm A with time complexity f(n) can handle in one year. We assume that f(n) is expressed in milliseconds. If f(n) = n3, then Algorithm A can handle in one year a problem of size n up to ________.

3,159

Provide a numerical value. The objective of this exercise is to find the largest input size N that an algorithm A with time complexity f(n) can handle in one year. We assume that f(n) is expressed in milliseconds. If f(n) = n4, then Algorithm A can handle in one year a problem of size n up to ________.

421

Numerical Answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of comparisons performed. Line 3 performs _________ comparisons. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 2 to 5 4: if (a < A[j]) 5: a = A[j] 6: return(a)

5

Numerical Answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of comparisons performed. Line 4 performs _________ comparisons. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to 5 4: if (a < A[j]) 5: a = A[j] 6: return(a)

5

Select the best answer. Suppose Kevin wants to prove A --> (n is odd) using contradiction. He should start by assuming _____________.

A and (n is odd)

Select the best answer. Suppose Kevin wants to prove A --> B using contradiction. He should start by assuming _____________.

A and not(B)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = n3, b(n) = n, c(n) = ln(n), d(n) = n2 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f2(n) = a(n) then f1(n) = [name1].

None of these answers

Check all that apply. Mathematical induction involves two steps or cases: ___________ and ____________.

base induction

Select the best answer. Bob wants to prove a property P for all integer numbers n that are multiple of 3 using mathematical induction. After checking the base case, he must assume P for n and then prove P for _________.

n + 3

Select the best answer. Let the function f(n) defined as: f(n) = 1,000,000n100 + 0.000000001 (1.2)n+ 1,000,000 f(n) grows as [name1] (1.2)^n n^100 Constant 1,000,000

(1.2)^n

Select the best answer. We want to prove S=∑i=0ni=n(n+1)2 For the base case, the value of S is ________.

0

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 1.1n, b(n) = 1000.n, c(n) = 1,000,000 ln(n), d(n) = 0.001n3 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f2(n) = a(n) then f1(n) = [name1]. f1 > f2

None of these answers

Check all that apply. A counterexample can be used to prove ____________:

a theorem is wrong an algorithm is incorrect an overall theory is wrong

Check all that apply. Check all loop invariants for the code below after each iteration. s = 0for (i=1; i <= n; i++) s = s + i

i <= n s = i (i+1)/2 i>=1

n-1 Sigma i = i = 1 Select from the dropdown menu.

n(n-1)/2

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of comparisons performed. Line 3 performs _________ comparisons. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to n 4: if (a < A[j]) 5: a = A[j] 6: return(a) n n+2 n+1 None of these answers n-1

n+1

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of additions performed. Line 3 performs _________ additions. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to n-1 4: if (a < A[j]) 5: a = A[j] 6: return(a)

n-1

Select the best answer. Bob wants to prove a property P for all integer numbers x (x > 0) using mathematical induction. He should first show P for _____.

x = 1

Select the best answer. Bob wants to prove a property P for all integer numbers x (x >= 1) using mathematical induction. He should first show P for _____.

x = 1

Select the best answer. Bob wants to prove a property P for all integer numbers x (x > 1) using mathematical induction. He should first show P for _____.

x = 2

Select the best answer. Bob wants to prove a property P for all positive real numbers x (x >= 0) using mathematical induction. He should first show P for _____.

None of these answers

Fill in multiple blanks. A is an example that opposes or an idea or a theory.

counterexample contradicts

Select the best answer. Consider this computational problem: "Find the maximum number of a sequence of integers". Check a valid input to this computational problem. the sequence (200.3, 10.1, 3.78, 4, 7) None of these answers the sequence (3, 10, 7, 4, 200) a number the sequence (3, 10, 7, 4.1, 200)

the sequence (3, 10, 7, 4, 200)

Check all that apply. A loop invariant property is ________________.

1. property that variables related to a loop satisfy 2. a (true) logical assertion about variables related to the loop 3. a true boolean statement about variables related to a loop

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of comparisons performed. Line 3 performs _________ comparisons. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to n-1 4: if (a < A[j]) 5: a = A[j] 6: return(a) None of these answers n+1 n+2 n-1 n

N

Select the best answer. Let the function f(n) defined as: f(n) = 4n + 0.1n3 + 1,000 n2 + 0.001 (1.2)n+ 1,000,000 f(n) grows as [name1]

None of these answers

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 3.n2, b(n) = 1000.n, c(n) = 1,000,000 ln(n), d(n) = 0.001n3 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f1(n) = b(n) then f2(n) = [name1]. f1>f2

c(n)

Check all that apply. Proving a loop invariant involves these steps:

initialization Maintenance Termination

Check all that apply. Check all loop invariants for the loop in the program below: a = 16for (j=0; j < 8; j++) T[j] = 0

j <= 8 a = 16* T[k] = 0 for 0 <= k <= (j-1) with j > 0

Select the best answer. We want to prove (the formula of the sum of the first n integers) S=∑i=0ni=n(n+1)2 The base case must be _______.

n = 0

Select the best answer. Bob wants to prove a property P for all integer numbers x (x >= 0) using mathematical induction. He should first show P for _____.

x = 0

3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 +15 = _____________ .

117

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 +15 = _____________ .

120

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the smallest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = 1 while ((index ≤ A.length) and (A[index]≠ e)) index = index + 1 if (index > A.length) index = -1 return(index) Given this problem instance [e=45, A=(3, 7, 54, 2, 100, 2, 45)], this algorithm will execute [ Select ] comparisons and will return [ Select ]

15 7

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the largest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = A.length while ((index > 0) and (A[index]≠ e)) index = index - 1 if (index <= 0) index = -1 return(index) Given this problem instance [e=4, A=(3, 7, 54, 2, 100, 2, 45)], this algorithm will execute [ Select ] comparisons and will return [ Select ]

16 -1

Provide a numerical value. The objective of this exercise is to find the largest input size N that an algorithm A with time complexity f(n) can handle in one year. We assume that f(n) is expressed in milliseconds. If f(n) = n2, then Algorithm A can handle in one year a problem of size n up to ________.

177,583

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the smallest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = 1 while ((index ≤ A.length) and (A[index]≠ e)) index = index + 1 if (index > A.length) index = -1 return(index) Given this problem instance with an n-items non empty sequence and a number e. This algorithm will perform at least [select] comparisons.

3

Select the best answer. Proving (establishing) a loop invariant requires ______ step/stage(s).

3

Numerical Answer. Instructions are numbered starting from 1. There is a loop invariant code at Line __________. Answer -1 if there is no loop invariant code. 1. s = 62. x = 2.03. for (i=0; i <= n; i++)4. b = 2 * (s + x) + b5. s = x*x + 26. a = a + s << 2

5

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the largest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = A.length while ((index > 0) and (A[index]≠ e)) index = index - 1 if (index <= 0) index = -1 return(index) Given this problem instance [e=100, A=(3, 7, 54, 2, 100, 2, 45)], this algorithm will execute [select] comparisons and will return [select]

7 5

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the largest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = A.length while ((index > 0) and (A[index]≠ e)) index = index - 1 if (index <= 0) index = -1 return(index) Given this problem instance [e=3, A=(3, 7, 54, 3, 100, 2, 45)], this algorithm will execute [ Select ] comparisons and will return [ Select ]

9 4

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the largest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = A.length while ((index > 0) and (A[index]≠ e)) index = index - 1 if (index <= 0) index = -1 return(index) Given this problem instance [e=3, A=(3, 7, 54, 3, 100, 2, 45)], this algorithm will execute [ Select ] comparisons and will return [ Select ]

9 4

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the smallest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = 1 while ((index ≤ A.length) and (A[index]≠ e)) index = index + 1 if (index > A.length) index = -1 return(index) Given this problem instance with an n-items sequence and a number e. In the best case, the number of comparisons for this algorithm will grow as Constant . Constant

:Constant

Select the best answer. The origin of the word Algorithm stems from _____________. None of these answers Erasthostenes Al Khawarizmi Euclid Averroes

Al Khawarizmi

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). This algorithm must find the smallest number in Sequence A. This algorithm may be flawed. If it is flawed, indicate the line that makes it incorrect (select the option that describes best what is wrong with it), otherwise select "correct". Procedure(A) 1: n= A.length 2: a = A[n] 3: for j = 1 to n-1 4: if (a > A[j]) 5: a = A[j] 6: return(a) Line 4 Line 3 Correct Line 2 Multiple lines

Correct

Check all that apply. A good algorithm must be ___________. Correct Have the smallest number of lines Be elegant Complete in the smallest amount of time Use the least memory space

Correct Complete in the smallest amount of time Use the least memory space

Select the best answer. The objective of this exercise is to find the largest input size N that an algorithm A with time complexity f(n) can handle in one year. We assume that f(n) is expressed in milliseconds. If f(n) = ln(n), then Algorithm A can handle in one year a problem of size n up to [name1]. Extremely large number (larger than all other options)) 365*24*3600*1,000,000 315,360x10^5 315,360x10^3 315,360 None of these answers

Extremely large number (larger than all other options))

True or False. Examine the following pseudocode. We are interested in the space complexity. The space complexity for the sum_nFirstIntegers(n) algorithm will increase as n increases. sum_nFirstIntegers(n) sum = 0 for j = 1 to n sum += j return(sum) True False

False

Select the best answer. Examine the following pseudocode and determine the problem it solves. Procedure(A) n= A.length a = A[1] for j = 1 to n if (a < A[j]) a = A[j] return(a) Sort Sequence A Find the smallest number of Sequence A Find the sum of the n first integers None of these answers Find the largest number of Sequence A

Find the largest number of Sequence A

Select the best answer. Examine the following pseudocode and determine the problem it solves. Procedure(A) n= A.length a = A[1] for j = 1 to n if (a > A[j]) a = A[j] return(a) Sort Sequence A Find the smallest number of Sequence A Find the largest number of Sequence A None of these answers Find the sum of the n first integers

Find the smallest number of Sequence A

Check all that apply. Pseudocode is similar to _______________. Java Plain English Plain French C Python Plain Arabic

Java Plain English Plain French C Python Plain Arabic

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). This algorithm must find the smallest number in Sequence A. This algorithm may be flawed. If it is flawed, indicate the line that makes it incorrect (select the option that describes best what is wrong with it), otherwise select "correct". Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to n 4: if (a < A[j]) 5: a = A[j] 6: return(a) Line 2 Line 4 Line 3 Correct Multiple lines

Line 4

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). This algorithm must find the smallest number in Sequence A. This algorithm may be flawed. If it is flawed, indicate the line that makes it incorrect (select the option that describes best what is wrong with it), otherwise select "correct". Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 2 to n 4: if (a < A[j]) 5: a = A[j] 6: return(a) Line 3 Line 2 Line 4 Multiple lines Correct

Line 4

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). This algorithm must find the smallest number in Sequence A. This algorithm may be flawed. If it is flawed, indicate the line that makes it incorrect (select the option that describes best what is wrong with it), otherwise select "correct". Procedure(A) 1: n= A.length 2: a = A[n] 3: for j = 1 to n 4: if (a < A[j]) 5: a = A[j] 6: return(a) Line 3 Correct Multiple lines Line 4 Line 2

Line 4

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of additions performed. Line 3 performs _________ additions. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to n 4: if (a < A[j]) 5: a = A[j] 6: return(a) None of these answers n+2 n-1 n n+1

N

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of comparisons performed. Line 3 performs _________ comparisons. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 2 to n 4: if (a < A[j]) 5: a = A[j] 6: return(a) n+2 n-1 n+1 n None of these answers

N

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the smallest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = 1 while ((index ≤ A.length) and (A[index]≠ e)) index = index + 1 if (index > A.length) index = -1 return(index) Given this problem instance with an n-items sequence and a number e. For any instance of this problem, this algorithm will always perform None of these answers comparisons.

None of these answers

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the smallest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = 1 while ((index ≤ A.length) and (A[index]≠ e)) index = index + 1 if (index > A.length) index = -1 return(index) Given this problem instance with an n-items sequence and a number e. For any instance of this problem, this algorithm will always perform [select] comparisons.

None of these answers

Select the best answer. Let the function f(n) defined as: f(n) = 4n + 0.1n3 + 1,000 n2 + 0.001 (1.2)n+ 1,000,000 f(n) grows as [name1]

None of these answers

Select from multiple dropdowns. Examine the following pseudocode. Each line is numbered (leftmost number). The objective of this exercise is to determine the time complexity of this algorithm that takes as input a sequence S of numbers and output the same sequence S' sorted in increasing order. First, this algorithm has a bug on line # [ Select ] . Line # 2 performs [ Select ] comparisons and n additions during the full execution of this algorithm. When j is equal to 5, the inner loop will execute [ Select ] ] times. When j is equal to 5, Line # 3 will perform [ Select ] comparisons. This algorithm will most likely grow like [ Select ] . sortArrayIncreasing(S) 1: n = S.length 2: for j = 1 to n-1 3: for i = j+1 to n 4: if (S[j] >= S[i]) 5: a =S[j] 6: S[j] = S[i] 7: S[i] = a 8: return

None of these answers n n-1 n-5 n-4 n^2

Check all that apply. Check algorithms among these Pascal's Triangle (also known as Pascal's Rule) Sequence Sorting This is a problem, not a solution! An algorithm is a solution. Euclid's method Sieve of Eratosthenes Insertion Sort

Pascal's Triangle (also known as Pascal's Rule) Euclid's method Sieve of Eratosthenes Insertion Sort

Select the best answer. The objective is to prove that when this program ends, we will have T[i] = 0 for all i from 0 to 7. Of all potential loop invariants in this question, check the best loop invariant before each iteration to use in order to achieve my objective. a = 16for (j=0; j < 8; j++) T[j] = 0

T[k] = 0 for 0 <= k <= (j-1) with j > 0

Select the best answer. The objective is to prove that when this program ends, we will have T[i] = 16 for all i from 0 to 7. Of all potential loop invariants in this question, check the best loop invariant before each iteration to use in order to achieve my objective. a = 16for (j=0; j < 8; j++) T[j] = a + ja = a - 1

T[k] = 16 for 0 <= k <= (j-1) with j >= 1

Select the best answer. Sara starts her proof with saying "try the value 5 with your code and check the output". Sara is likely trying to prove her point using ....

a counterexample

Select the best answer. Consider this computational problem: "Sorting a sequence in decreasing order". Check the valid input to this computational problem. a string of characters an integer None of these answers a sequence (3,10,7,4,200) an algorithm

a sequence (3,10,7,4,200)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 1.001n, b(n) = 1000.n, c(n) = 1,000,000 ln(n), d(n) = 0.001n7 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f2(n) = d(n) then f1(n) = [name1]. f1 > f2

a(n)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 1.001n, b(n) = 1000.n, c(n) = 1,000,000 ln(n), d(n) = 0.001n7 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f2(n) = d(n) then f1(n) = [name1]. f1>f2

a(n)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 1.2n, b(n) = 1000.n, c(n) = 1,000,000 ln(n), d(n) = 0.001n3 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f2(n) = d(n) then f1(n) = [name1]. f1 > f2

a(n)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 1.1n, b(n) = 1000.n, c(n) = 1,000,000 ln(n), d(n) = 0.001n3 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f2(n) = a(n) then f1(n) = [name1].

b(n)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 1.1n, b(n) = ln(ln(n)), c(n) = ln(n), d(n) = n2 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f1(n) = c(n) then f2(n) = [name1]. f1 > f2

b(n)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 1.1n, b(n) = ln(ln(n)), c(n) = ln(n), d(n) = n2 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f1(n) = c(n) then f2(n) = [name1]. f1>f2

b(n)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = n2, b(n) = n, c(n) = ln(n), d(n) = n3 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f1(n) = b(n) then f2(n) = [name1]. f1 > f2

c(n)

Select the best answer. The objective of this exercise is to identify a function among 4 different functions a(n), b(n), c(n), and d(n) using the growth of rate. a(n) = 3.n2, b(n) = 1000.n, c(n) = 1,000,000 ln(n), d(n) = 0.001n3 The graph below is a hint about two functions f1(n) and f2(n). We do not know the range or the x-axis values. If f2(n) = a(n) then f1(n) = [name1]. F1 > f2

d(n)

Select the best answer from each dropdown menu. Consider the statement "All birds can fly". This statement is [ Select ] ["true", "almost true", "false"] : a counterexample is [ Select ] ["penguins", "sparrow", "eagle", "None of these answers", "pigeon"] . A [ Select ] ["penguin", "eagle", "None of these answers", "sparrow", "pigeon"] is a bird, but it [ Select ] ["can", "will", "None of these answers", "would", "cannot"] fly.

false penguins penguin cannot

Select the best answer. The Sieve of Eratosthenes is an algorithm to ________________. find the greatest common divisor of two numbers measure the Earth Inclination None of these answers measure the Earth circumference Correct! find prime numbers

find prime numbers

Select the best answer. The Euclid's algorithm is an algorithm to ________________. None of these answers measure the Earth circumference find prime numbers measure the Earth Inclination find the greatest common divisor of two numbers

find the greatest common divisor of two numbers

Select the best answer. The Euclid's algorithm is an algorithm to ________________. measure the Earth circumference Correct! find the greatest common divisor of two numbers measure the Earth Inclination None of these answers find prime numbers

find the greatest common divisor of two numbers

Check all that apply. The objective is to prove that when this program ends, m will be the smallest value in Array A. Check all loop invariants for the code below before the iteration. m = A[1]for (i=2; i <= A.length; i++) if (m > A[i])m = A[i]

i <= A.length m <= A[1] i >=2 m <= A[k] for all k such that 1 <= k <= (i-1)

Check all that apply. The objective is to prove that when this program ends, m will be the smallest value in Array A. Check all loop invariants for the code below before the iteration. m = A[1]for (i=2; i <= A.length; i++) if (m > A[i])m = A[i]

i >=2 i <= A.length m <= A[k] for all k such that 1 <= k <= (i-1) m <= A[1]

Select the best answer for each dropdown menu. Consider this program that should return the largest value in Array A. maxval(A) { currmax = 255; for (i=0; i < A.length; i++) if (A(i) > currmax) currmax = A(i) //A(i) is the ith element in Array A return currmax } This program is incorrect . A counterexample could be the array A={100, 34, 4, 1, 5} .

incorrect {100, 34, 4, 1, 5}

Select the best answer for each dropdown menu. Consider this program that should return the smallest value in Array A. minval(A) { currmin = 0; for (i=0; i < A.length; i++) if (A(i) < currmin) currmin = A(i) //A(i) is the ith element in Array A return currmin } This program is [ Select ] ["perfect", "incorrect", "correct", "None of these answers", "optimal"] . A counterexample could be the array A= [ Select ] ["{20, 34, -1, 10, 6}", "{2000, 34, 4, 1, 5}", "None of these answers", "{0, 1, 2, -3, 5}"] .

incorrect {2000, 34, 4, 1, 5}

Fill in the blank. Proving a loop invariant consists of _____________, maintenance, and termination steps.

initialization

Check all that apply. Check all loop invariants before the iteration for the loop in the program below: a = 13for (j=0; j < 8; j++) a = a - 1

j <= 7 a >= 5 j + a = 13

Select the best answer. The objective is to prove that when this program ends, m will be the smallest value in Array A. Of all potential loop invariants in this question, check the best loop invariant before each iteration to use in order to achieve my objective. m = A[1]for (i=2; i <= A.length; i++) if (m > A[i])m = A[i]

m <= A[k] for all k such that 1 <= k <= (i-1)

Select the best answer. Loop invariants technique is closest to the ___________ technique.

mathematical induction

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of additions performed. Line 3 performs _________ additions. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to n 4: if (a < A[j]) 5: a = A[j] 6: return(a)

n

Select the best answer. Examine the following pseudocode. Each line is numbered (leftmost number). We are interested in the number of comparisons performed. Line 3 performs _________ comparisons. Procedure(A) 1: n= A.length 2: a = A[1] 3: for j = 1 to n-1 4: if (a < A[j]) 5: a = A[j] 6: return(a)

n

Select the best answer. Let the function f(n) defined as: f(n) = 4n + 10.5n + 1,000,000 f(n) grows as [name1] n Constant 4n 10.5n None of these answers

n

Select the best answer. Bob wants to prove a property P for all integer numbers n (n >= 1) using mathematical induction. After checking the base case, he must assume P for n and then prove P for _________.

n + 1

Select the best answer. Bob wants to prove a property P for all even integer numbers n using mathematical induction. After checking the base case, he must assume P for n and then prove P for _________.

n + 2

Select the best answer. Bob wants to prove a property P for all odd integer numbers n using mathematical induction. After checking the base case, he must assume P for n and then prove P for _________.

n + 2

Select the best answer. Bob wants to prove a property P for all odd positive integer numbers n using mathematical induction. His base case must be.

n = 1

Select the best answer from each dropdown menu. Examine this algorithm. Given a sequence A and an element e, this algorithm returns the smallest index of e in Sequence A if A contains e. If A does not contain e, this algorithm returns -1. find-Element(e,A) index = 1 while ((index ≤ A.length) and (A[index]≠ e)) index = index + 1 if (index > A.length) index = -1 return(index) Given this problem instance with an n-items sequence and a number e. Assuming that e is in A, this algorithm will perform on average [select] comparisons.

n+1

Select from multiple dropdowns. Examine the following pseudocode. Each line is numbered (leftmost number). The objective of this exercise is to determine the time complexity of this algorithm that takes as input two n x n matrix A and B and computes their product C=A*B. We assume that the first line starts at i=1 and the first column starts at j =1. For any matrix M, we designate M(i,j) the element on the ith line and jth column. In total, this algorithm performs the statement S = 0 (Line # 4) [ Select ] times. In total, this algorithm performs the addition in Line # 6 [ Select ] times. In total, this algorithm performs the multiplication in Line # 6 n^3 times. The total number of additions (Line #6) grows as [ Select ] . The total number of multiplications (Line #6) grows as [ Select ] . The total number of additions and multiplications performed in Line # 6 is [ Select ] .The total number of additions and multiplications performed in Line # 6 grows as [ Select ] . To determine the time complexity, the action to consider should be [ Select ] . matrixProduct(A,B) 1: //Computes C = A*B 2: for i = 1 to n 3: for j = 1 to n 4: S = 0 5: for k=1 to n 6: S = S + A(i,k) * B(k,j) 7: C(i,j) = S 8: return

n^2 n^3 n^3 n^3 n^3 2n^3 n^3 either multiplication OR addition in Line #6

Select the best answer. Examine the following pseudocode. We are interested in the space complexity. Using a space unit similar to what was used in class, the Initialize() algorithm will use ___________ space units Initialize(M) // M is an n by n matrix for j = 1 to n for j = 1 to n M[i][j] = 0

n^2 + 2

Select the best answer. Examine the following pseudocode. We are interested in the space complexity. Using a space unit similar to what was used in class, the Initialize() algorithm will use ___________ space units Initialize(M) // M is an n by n matrix for j = 1 to n for j = 1 to n M[i][j] = 0 None of these answers n^2 n + 2 n n^2 + 2

n^2 + 2

Select the best answer. Examine the following pseudocode. We are interested in the space complexity. Using a space unit similar to what was used in class, the Initialize() algorithm will use ___________ space units Initialize(M) // M is an n by n matrix for j = 1 to n for j = 1 to n M[i][j] = 0 n n^2 n + 2 n^2 + 2 None of these answers

n^2 + 2

Select the best answer. The objective is to prove that when this program ends, s = n. Of all potential loop invariants in this question, check the best loop invariant before each iteration to use in order to achieve my objective. s = 0for (i=1; i <= n; i++) s = s + 1

s <= i - 1 for all i > 0

Select the best answer. The objective is to prove that when this program ends, s = n. Of all potential loop invariants in this question, check the best loop invariant before each iteration to use in order to achieve my objective. s = 0for (i=1; i <= n; i++) s = s + 1

s = i -1 for all i > 0

Proving a loop invariant consists of initialization, maintenance, and _____________ steps.

termination

Select the best answer. Consider this computational problem: "Determine the index of a number e in a sequence S of integers". Check a valid instance of the problem.

the number 5 and the sequence (3, 10, 7, 4, 200)

Select the best answer. Consider this computational problem: "Determine the index of a number e in a sequence S of integers". Check a valid instance of the problem. the number 6.6 and the sequence (200.3, 10.1, 3.78, 4, 7) a number None of these answers the number 5 and the sequence (3, 10, 7, 4, 200) a number 5 and the sequence (3, 10, 7, 4.1, 200)

the number 5 and the sequence (3, 10, 7, 4, 200)

Select the best answer. Consider this computational problem: "Sorting a sequence in decreasing order". Check a correct output. the sequence (200, 10, 3, 4, 7) None of these answers the sequence (200, 10, 7, 4, 3) the sequence (3, 10, 7, 4, 200) the sequence (200, 4, 7, 10, 3)

the sequence (200, 10, 7, 4, 3)

Select the best answer. Consider this computational problem: "Find the maximum number of a sequence of integers". Check a valid input to this computational problem.

the sequence (3, 10, 7, 4, 200)

Select the best answer. The objective is to prove that when this program ends, x + y = a. Of all potential loop invariants in this question, check the best loop invariant before each iteration to use in order to achieve my objective. x = ay = 0while (x > 0) x--y++

x + y = a

Check all that apply. Check all loop invariants for the loop in the program below: x = a // a is a positive numbery = 0while (x > 0) x--y++

x <= a x + y = a y <= a


संबंधित स्टडी सेट्स

2nd 9 Weeks WORLD GEOGRAPHY Exam

View Set

Reading 2 - Organizing, Visualizing, and Describing data

View Set

Nursing care during labor and delivery (test 2)

View Set

"Night To Remember" Study guide (Blazek)

View Set

Psychology - Chapter 15 - Social Psychology

View Set

Analyzing Financial Statements (Final Study Guide)

View Set