Topic: Chapter 8: Iteration and recursion



Topic: Chapter 8: Iteration and recursion
Q.1
In iteration, the loop body is repeatedly executed as long as the loop condition is
A. true
B. false
C. empty
D. none of above
Answer : Option A
Explaination / Solution:
No Explaination.


Workspace
Report
Q.2
A loop invariant need not be true
A. at the start of the loop.
B. at the start of each iteration
C. at the end of each iteration
D. at the start of the algorithm
Answer : Option D
Explaination / Solution:
No Explaination.


Workspace
Report
Q.3
Recursion must have
A. negative base case
B. zero base case
C. at least one base case
D. none of above
Answer : Option C
Explaination / Solution:
No Explaination.


Workspace
Report
Q.4
We wish to cover a chessboard with  dominoes, the number of black squares and the number of white squares covered by dominoes, respectively, placing a domino can be modeled by
A. b := b + 2
B. w := w + 2
C. b, w := b+1, w+1
D. b := w
Answer : Option D
Explaination / Solution:
No Explaination.


Workspace
Report
Q.5
An invariant for the loop body is known as a
A. state condition
B. loop marker
C. zero invariant
D. loop invariant
Answer : Option D
Explaination / Solution:
No Explaination.


Workspace
Report
Q.6
If m x a + n x b is an invariant for the assignment a, b : = a + 8, b + 7, the values of m and n are
A. m = 8, n = 7
B. m = 7, n = -8
C. m = 7, n = 8
D. m = 8, n = -7
Answer : Option B
Explaination / Solution:
No Explaination.


Workspace
Report
Q.7
A loop invariant is true at
A. at the start of the loop (just before the loop)
B. at the start of each iteration (before loop body)
C. at the end of each iteration (after loop body)
D. all the above
Answer : Option D
Explaination / Solution:
No Explaination.


Workspace
Report
Q.8
Which of the following is not an invariant of the assignment? m, n := m+2, n+3
A. m mod 2
B. n mod 3
C. 3 X m - 2 X n
D. 2 X m - 3 X n
Answer : Option D
Explaination / Solution:
No Explaination.


Workspace
Report
Q.9
A loop invariant need not be true
A. at the start of the loop.
B. at the start of each iteration
C. at the end of each iteration
D. at the start of the algorithm
Answer : Option D
Explaination / Solution:
No Explaination.


Workspace
Report
Q.10

If Fibonacci number is defined recursively as


to evaluate F(4) ,how many. timesF() is applied?
A. 3
B. 4
C. 8
D. 9
Answer : Option A
Explaination / Solution:
No Explaination.


Workspace
Report