Quiz

1. How many stars will the following code output for a given positive value of n:
2. ```    void fun1(int n)
{
int i = 0;
if (n > 1)
fun1(n-1);
for (i = 0; i < n; i++)
printf(" * ");
}
```
a. n
b. n^2
c. n(n-1)/2
d. n(n+1)/2

3. For every recursive solution, there is a corresponding iterative solution
4. a. True
b. False

5. What will be the ouptut of the following function call: fun2(20); where fun2 is defined as:
6. ```    void fun2(int n)
{
if(n > 100)
return;
printf("%d ", n);
fun2(2*n);
printf("%d ", n);
}
```
a. 20 40 60 80 60 40 20
b. 80 60 40 20
c. 20 40 60 80 80 60 40 20
d. 20 40 60 80

7. What will be the ouptut of the following function call: fun3(100); where fun3 is defined as:
8. ```    int fun3(int n)
{
if(n == 1)
return 0;
else
return 1 + fun1(n/2);
}
```
a. 6
b. 7
c. 5
d. 4

9. What will be the ouptut of the following function call: fun4(4,3); where fun4 is defined as:
10. ```    int fun4(int x, int y)
{
if(x == 0)
return y;
else
return fun1(x - 1,  x + y);
}
```
a. 13
b. 14
c. 3
d. 7

11. A recursive function must necessarily make a call to
12. A is required so that there is no infinite recursive calling of the same function.