Question: Consider the following Algorithms and answer the questions Algorithm 1 int fun1(int n) { if (n
Consider the following Algorithms and answer the questions
| Algorithm 1 | int fun1(int n) { if (n <= 1) return n; return 2*fun1(n-1); } |
| Algorithm 2 | int fun2(int n) { if (n <= 1) return n; return fun2(n-1) + fun2(n-1); } |
- If n=8, what will be the final return value of both algorithms?
- Write both algorithms using loops strategy.
Step by Step Solution
3.49 Rating (162 Votes )
There are 3 Steps involved in it
nt fun1int n if n 8 return n else return 2funn1 int main printfd fun2 return 0 output 32 This is the first time we are going to make an attempt to move backward in a program Loops make this backward m... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (2 attachments)
6360f8c30c158_235189.pdf
180 KBs PDF File
6360f8c30c158_235189.docx
120 KBs Word File
