11th Standard Syllabus & Materials
11th Standard
TN 11th Tamil இயற்கை வேளாண்மை,சுற்றுச்சூழல் -செய்யுள் - மனோன்மணீயம் Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil என்னுயிர் என்பேன் -துணைப்பாடம் - இசைத்தமிழர் இருவர் Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil மொழி கலை -செய்யுள் - ஒவ்வொரு புல்லையும் Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil பீடு பெற நில் - இலக்கணம் - பகுபத உறுப்புகள் Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil பீடு பெற நில் - துணைப்பாடம் - வாடிவாசல் Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil பீடு பெற நில் - செய்யுள் - குறுந்தொகை Important Questions And Answers Study Material - QB365 Set A

Published on: 14/12/2019
Iteration and recursion
Download Tamil Nadu 11th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
When will the loop variant be true?
2.
Define factorial of a natural number recursively
3.
What is the relationship between loop invariant, loop condition and the input-output recursively?
4.
Does testing the loop condition affect the loop invariant? Why?
5.
What is an invariant?
6.
Write a note on Recursion.
7.
Using a loop variant how will you construct a loop?
8.
What are the important points in which a loop variant is true?
9.
A knockout tournament is a series of games. Two players compete in each game; the loser is knocked out (i.e. does not play anymore), the winner carries on. The winner of the tournament is the player that is left after all other players have been knocked out. Suppose there are 1234 players in a tournament. How many games are played before the tournament winner is decided?
10.
There are 7 tumblers on a table, all standing upside down. You are allowed to turn any 2 tumblers simultaneously in one move. Is it possible to reach a situation when all the tumblers are right side up? (Hint: The parity of the number of upside-down tumblers is invariant.)
11.
Design a recursive algorithm to compute an, We constructed an iterative algorithm to compute an in Example 8.5. an can be defined recursively as
\(a^n= \begin{cases}1 & \text { if } \mathrm{n}=0 \\ a^n \times a^{n -1} & \text { otherwise }\end{cases}\)
12.
Explain recursive - problem solving.
13.
Explain how will you solve a problem recursively.
14.
Power can also be defined recursively as
\(a^n= \begin{cases}1 & \text { if } \mathrm{n}=0 \\ \mathrm{a} \times \mathrm{a}^{\mathrm{n}-1} & \text { if } \mathrm{n} \text { is odd } \\ \mathrm{a}^{\mathrm{n} / 2} \times \mathrm{a}^{\mathrm{n} / 2} & \text { if } \mathrm{n} \text { is even }\end{cases}\)
Construct a recursive algorithm using this definition. How many multiplications are needed to calculate a10?
15.
The input size to a sub problem is __________ than the input size to the original problem.
equal
smaller
greater
no criteria
16.
In a loop, if L is an invariant of the loop body B, then L is known as a __________
recursion
variant
loop invariant
algorithm
17.
In which year E W Dijkstra was awarded ACM Turing Award?
1972
1974
1970
1971
18.
Which of the following is a recursive solver case?
Base case
Recursive case
loop case
Both a and b
19.
How many cases are there a recursive solver has_______.
2
3
4
many
1.
The loop invariant is true before the loop body and after the loop body, each time.
2.
\(\text { Fact }(\mathrm{n})=\left\{\begin{array}{l}
1 \text { if } \mathrm{n}=0 \\
\mathrm{n} * \text { fact }(\mathrm{n}-1) \text { otherwise }
\end{array}\right.\)
Recursive Algorithm:
Fact (n)
-- inputs: n
outputs: Fact=n!
if(n-0)- --base case
otherwise
1
else
n fact (n-1)--recursive step
3.
A loop invariant is a condition [among program variables] that is necessarily true immediately before and immediately after, each iteration of a loop. A loop invariant is some condition that holds for every iteration of the loop.
4.
No, the loop condition do not affect the loop invariant. Because the loop invariant is true at four points.
(i) at the start of loop
(ii) at the start of each iteration
(iii) at the end of each iteration
(iv) at the end of the loop
5.
An expression involving variables, which remains unchanged by an assignment to one of these variables is called as an invariant of the assignment.
6.
Recursion:
Recursion is another algorithm design technique, closely related to iteration, but more powerful. Using recursion, we solve a problem with a given input, by solving the same problem with" a part of the input, and constructing a solution to the original problem from the solution to the partial input.
7.
(i) Establish the loop invariant at the start of the loop.
(ii) The loop body should so update the variables as to progress toward the end and maintain the loop invariant, at the same time.
(iii) When the loop ends, the termination condition and the loop invariant should establish the input-output relation
8.
a loop variant, then it is true at four important points in the algorithm
(i) at the start of the loop (just before the loop).
(ii) at the start of each iteration (before loop body)
(iii) at the end of each iteration (after loop body).
(iv) at the end of the loop (just after the loop).
9.
| No. of players | 2 | 3 | 4 | 5 | n | 1234 |
| No. of games | 1 | 2 | 3 | 4 | n - 1 | 1234 - 1 = 1233 |
On the other hand let n be the number of games played and r be the number of players remaining in the tournament.
After every game, r will be reduced by 1.
r → no. of players remaining
n → no. of games played
If r=2 then n=1
As n increases, r decreases
n,r: n+1,r-1
n+r=(n+1)+(r-1)
= n + 1 + r - 1
= n + r
Therefore n + r is invariant.
n+r=1234 (No. of players initially)
The winner of the tournament is the player that is left after all other players have been knocked out.
After all the games, only one player (winner) is left out.
i. c. n = 1
Put n = 1 in (1)
n+r=1234 ....(1)
1+r=1234
r = 1234-1-1233
No. of games played = 1233
10.
Let u - No. of tumblers right side up
v - No. of tumblers up side down
Initial stage: u = 0, v=7 (All tumblers upside down)
Final stage output: u=7, v=0 (All tumblers right side up)
Possible Iterations:
(i) Turning both up side down tumblers to right side up
u=u+ 2, v=y-2 [u is even]
(ii) Turning both right side up tumblers to upside down.
u=u-2, v=v+2 [u is even]
(iii) Turning one right side up tumblers to upside down and other tumbler from upside down to right side up.
u=u+1-1=u, v=y+1-1=v [u is even]
Initially u = 0 and continuous to be even in all the three cases. Therefore u is always even.
Invariant: u is even (i. e. No. of right side up tumblers are always even)
But in the final stage (Goal), u = 7 and v=0 i. e. u is odd.
Therefore it is not possible to reach a situation where all the tumblers are right side up.
11.
The recursive definition can be expressed as a recursive solver for computing power(a, n).
power (a, n)
-- inputs: n is an integer, n \(\ge\) 0
-- outputs : an
if n = 0 -- base case
1
else --recursion step
a x power (a, n-1)
The recursive process with solvers for calculating power(2, 5).·
The recursive process resulting from power(2, 5)
power (2,5)
= 2 x power (2,4)
= 2 x 2 x power(2,3)
= 2 x 2 x 2 x power(2, 2)
= 2 x 2 x 2 x 2 x power (2,1)
= 2 x 2 x 2 x 2 x 2 x power (2,0)
= 2 x 2 x 2 x 2 x 2 x 1
= 2 x 2 x 2 x 2 x 2
= 2 x 2 x 2 x 4·
= 2 x 2 x 8
= 2 x 16
= 32
12.
To solve a problem recursively, the solver reduces the problem to sub-problems, and calls another instance of the solver, known as sub-solver, to solve the sub-problem. The input ,size to a sub-problem is smaller than the input size to the original problem. When the solver calls a sub-solver, it is known as recursive call. The magic of recursion allows the solver to assume that the sub-solver (recursive call) outputs the solution to the sub-problem. Then, from the, solution to the sub-problem, the solver constructs the solution to the given problem.
As the sub-solvers go on reducing the problem into sub-problems of smaller sizes, eventually the sub-problem becomes small enough to be solved directly, without recursion. Therefore, a recursive solver has two cases:
1. Base case: The problem size is small enough to be solved directly. Output the solution. here must be at least one base case.
2. R-ecursion step: The problem size is not small enough. Deconstruct the problem into a sub-problem, strictly smaller in size than the given problem. Call a sub-solver to solve the sub problem. Assume that the sub-solver outputs the solution to the sub problem. Construct the solution to the given problem.
This outline of recursive problem solving technique is shown below.
solver (input)
if input is small enough
construct solution
else
find sub_Problems of reduced
input
solutions to sub problems =
solver for each sub .Problem
construct solution to the
problem from
solutions to the sub_problems
Whenever we solve a problem using recursion, we have to ensure these two cases: In the recursion step, the size of the input to the recursive call is strictly smaller than the size of the given input, and there is at least one base case.
13.
To solve a problem recursively, the solver reduces the problem to sub-problems, and calls another instance of the solver, known as sub-solver, to solve the sub-problem. The input size to a sub-problem is smaller than the input size to the original problem. When the solver calls a sub-solver, it is known as recursive call. The magic of recursion allows the solver to assume that the sub-solver (recursive call) outputs the solution to the sub-problem. Then, from the solution to the sub-problem, the solver constructs the solution to the given problem.
As the sub-solvers go on reducing the problem into sub-problems of smaller sizes, eventually the subproblem becomes small enough to be solved directly, without recursion. Therefore, a recursive. solver has two cases:
1. Base case: The problem size is small enough to be solved directly. Output the solution. There must be at least one base case.
2. Recursion step: The problem size is not small enough. Deconstruct the problem into a subproblem, strictly smaller in size than the given problem. Call a. sub-solver to solve the subproblem.
solver (input)
if input is small enough
construct solution
else
find sub_problems of reduced
input
solutions to sub_problems = solver for each sub_problem
construct a solution to the problem from
solutions to the sub_problems
Whenever we solve a problem using recursion, we have to ensure these two cases: In the recursion step, the size of the input to the recursive call is strictly smaller than the size of the given input, and there is at least one base case.
14.
power (5,2) = 5 × 5 = 25
power (x, n) raise x to the power n
Algorithm :
power (x, n)
If n = 0 -- base case
1
else -- rrecursion step
if n is odd
x * power (x, n - 1)
else
p = power (x, n/2)
p * p
To find a 10 :
15.
(b)
smaller
16.
(c)
loop invariant
17.
(a)
1972
18.
(d)
Both a and b
19.
(a)
2
11th Standard Syllabus & Materials
11th Standard
TN 11th Tamil பீடு பெற நில் - செய்யுள் - காவடிச்சிந்து Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil பீடு பெற நில் - உரைநடை - மலை இடப்பெயர்கள் : ஓர் ஆய்வு Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil மாமழை போற்றுதும் - துணைப்பாடம் - யானை டாக்டர் Important Questions And Answers Study Material - QB365 Set A
NEW11th Standard
TN 11th Tamil மாமழை போற்றுதும் - செய்யுள் - ஐங்குறுநூறு Important Questions And Answers Study Material - QB365 Set A
Tamilnadu Stateboard 11th Standard Subjects

Maths

Commerce

Economics

Biology

Business Maths and Statistics

Accountancy

Computer Science

Physics

Chemistry

Maths

Biology

Economics

Physics

Chemistry

History

Business Maths and Statistics

Computer Science

Accountancy

Computer Applications

History

Computer Technology

Commerce

Computer Applications

Computer Technology

Tamil

English

French
Tamilnadu Stateboard Standards