Question 12 Marks
Write a program using recursive function to accept the number from the user and print sum of first even n natural numbers.
10 questions · timed · auto-graded
Total: 21 operations => 21 units of processing time Therefore, the time Complexity is of the order O(1).
Therefore, the time complexity is of the order O(1) Total: 71 operations => 71 units of processing time Therefore, the time complexity is of the order O(1).
| Recursion | Iteration |
• Due to function calling overhead execution of recursion is slower. | • Whereas execution of iteration is faster.
|
• In recusion, a stack is used to store the set of new local variables and parameters, each time the function is called. | • Iteration does not use the stack.
|