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: 06/09/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.
Using this recursive definition
\(a^n= \begin{cases}1 & \text { if } n=0 \\ a \times a^{n-1} & \text { otherwise }\end{cases}\)
how many multiplications are needed to calculate a10?
11
10
9
8
2.
If Fibonacci number is defined recursively as
\(F(n)= \begin{cases}0 \ \mathrm{n}=0 \\ 1 \ \mathrm{n}=1 \\ \mathrm{~F}(\mathrm{n}-1)+\mathrm{F}(\mathrm{n}-2) \text { otherwise }\end{cases}\)
to evaluate F(4), how many times F() is applied?
3
4
8
9
3.
Which of the following is not an invariant of the assignment? m, n := m+2, n+3
m mod 2
n mod 3
3 x m - 2 x n
2 x m - 3 x n
4.
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
m = 8, n = 7
m = 7, n = -8
m = 7, n = 8
m = 8, n = -7
5.
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
b:= b + 2
w:= w + 2
b, w := b + 1, w + 1
b:= w
6.
A loop invariant need not be true
at the start of the loop
at the start of each iteration
at the end of each iteration
at the start of the algorithm
7.
Define factorial of a natural number recursively
8.
What is recursive problem solving?
9.
What is the relationship between loop invariant, loop condition and the input-output recursively?
10.
Does testing the loop condition affect the loop invariant? Why?
11.
Define a loop invariant.
12.
What is an invariant?
13.
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?
14.
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.)
15.
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?
1.
(c)
9
2.
(a)
3
3.
(d)
2 x m - 3 x n
4.
(b)
m = 7, n = -8
5.
(d)
b:= w
6.
(d)
at the start of the algorithm
7.
\(\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
8.
1. Recursion is a method of solving problems that involves breaking a problem down into smaller and smaller sub problems until user gets in to a small problem that it can be solved trivially.
2. Usually recursion involves a function calling itself. While it may not seem like much on the surface, recursion allows us to write elegant solutions to problems that may otherwise be very difficult to program.
9.
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.
10.
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
11.
In iteration, the loop body is repeatedly executed as long as the loop condition is true. Each time the loop body is executed, the variables are updated.
However, there is also a property of the variables which remains unchanged by the execution of the loop body. This unchanging property is called the loop invariant.
12.
An expression involving variables, which remains unchanged by an assignment to one of these variables is called as an invariant of the assignment.
13.
| 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
14.
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.
15.
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 :
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