Consider the following Algorithms and answer the questions Algorithm 1 int fun1(int n) { if (n
Fantastic news! We've Found the answer you've been seeking!
Question:
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.
Related Book For
Database management systems
ISBN: 978-0072465631
3rd edition
Authors: Raghu Ramakrishan, Johannes Gehrke, Scott Selikoff
Posted Date: