11th Standard Syllabus & Materials
11th Standard
TN 11th English Supplementary - 3 - The First Patient (Play) Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Prose - 3 - Forgetting Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Prose - 2 - The Queen of Boxing Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Poem - 1 - Once Upon A Time Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Prose - 1 - The Portrait of a Lady Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications Tamil Computing Sample Question Papers Study Material - QB365 Set A

Published on: 04/10/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.
Write a note on Iteration.
2.
Write a note on Recursion.
3.
Using a loop variant how will you construct a loop?
4.
What are the important points in which a loop variant is true?
5.
Consider two variable m and n under the assignment m, n : = m + 3, n - 1. Is the expression m + 3n an invariant?
6.
Show that p - c is an invariant of the assignment. P, C : = P + 1, C + 1
7.
How will you solve a problem using recursion?
8.
Write a note on loop variant?
9.
What is the use of repeating the same action again and again?
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.)
1.
Iteration:
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. Loop invariant is the key to construct and to reason about iterative algorithms.
2.
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.
3.
(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
4.
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).
5.
Let P(m, n) = m + 3n. Then
P(m, n) [m, n := m + 3, n -1]
= m + 3n [m, n := m + 3, n -1]
= (m + 3) + 3(n -1)
= m + 3 + 3n - 3
= m + 3n
= P(m, n)
Since (m + 3n) [m, n : = m + 3, n - 1] = m + 3n, m + 3n an invariant of the assignment m, n := m + 3, n-1.
6.
Let P (p, c) = p - c. Then
P (p, c) [p, c := p + 1, c + 1]
= p - c [p, c := p + 1, c + 1]
= (p + 1)-(c + 1)
= p-c
= p(P, c)
Since (p - c) [p, c := p + 1, c + 1] = p - c, p - c is an invariant of the assignment p, c := p + 1, c + 1.
7.
Recursion is another algorithm design technique, closely related to iteration. 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.
8.
(I) 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.
(ii) However, there is also a property of the variables which remains unchanged by the execution of the loop body.
(iii) This unchanging property is called the loop invariant. Loop invariant is the key to construct and to reason about iterative algorithms.
9.
(i) Even though the action is the same, the state in which the action is executed is not the same. Each time we execute the action, the state changes.
(ii) Therefore, the same action is repeatedly executed, but in different states.
(iii) The state changes in such a way that the process progresses to achieve the desired input-output relation.
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.
11th Standard Syllabus & Materials
11th Standard
TN 11th Computer Applications Computer Ethics and Cyber Security Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications JavaScript Functions Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications Control Structure in JavaScript Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications Introduction to JavaScript Sample Question Papers 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