MABS Institution
11th Computer Science Weekly Test -1 ( Iteration and recursion )-Aug 2020
-
-
-
-
-
-
-
-
-
-
-
-
-
-
When will the loop variant be true?
-
Write a note on Recursion.
-
How will you solve a problem using recursion?
-
Using a loop variant how will you construct a loop?
-
-
King Vikramaditya has two magic swords. With one,he can cut off 19 heads of a dragon, but after that the dragon grows 13 heads. With the other sword, he can cut off 7 heads, but 22 new heads grow. If all heads are cut off, the dragon dies.If the dragon has originally 1000 heads, can it ever die?
(Hint :The number of heas mod 3 is invariant .) -
What is the use of repeating the same action again and again?
-
-
Give an example for loop invariant.
-
Power can also be defined recursively as \({ a }^{ n }=\begin{cases} 1\quad \quad \quad \quad \quad \quad ifn=0 \\ a\times { a }^{ n }-1\quad \quad ifn\quad is\quad odd \\ { a }^{ n/2 }\times an/2\quad ifn\quad is\quad even \end{cases}\) Construct a recursive algorithm using this definition. How many multiplications are needed to calculate a10?
-
Explain how will you solve a problem recursively.
-
-
There are 6 equally spaced trees and 6 sparrows sitting on these trees,one sparrow on each tree. If a sparrow flies from one tree to another, then at the same time, another sparrow flies from its tree to some other tree the same distance away, but in the opposite direction. Is it possible for all the sparrows to gather on one tree?
-
Explain recursive- problem solving.
-