Algorithms | Recursion | Question 4
What does the following function do?
int fun( int x, int y) { if (y == 0) return 0; return (x + fun(x, y-1)); } |
chevron_right
filter_none
(A) x + y
(B) x + x*y
(C) x*y
(D) xy
Answer: (C)
Explanation: The function adds x to itself y times which is x*y.
Quiz of this Question
Recommended Posts:
- Algorithms | Recursion | Question 2
- Algorithms | Recursion | Question 8
- Algorithms | Recursion | Question 9
- Algorithms | Recursion | Question 7
- Algorithms | Recursion | Question 6
- Algorithms | Recursion | Question 9
- Algorithms | Recursion | Question 3
- Algorithms | Recursion | Question 5
- Algorithms | Analysis of Algorithms (Recurrences) | Question 9
- Algorithms | Analysis of Algorithms (Recurrences) | Question 3
- Algorithms | Analysis of Algorithms (Recurrences) | Question 11
- Algorithms | Analysis of Algorithms (Recurrences) | Question 8
- Algorithms | Analysis of Algorithms (Recurrences) | Question 7
- Algorithms | Analysis of Algorithms (Recurrences) | Question 6
- Algorithms | Analysis of Algorithms (Recurrences) | Question 2