Instructions
- 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
- 2. Thoroughly review each solution before proceeding to ensure full understanding.
- 3. Final results will be available after submission to provide insights into areas for further improvement.
- 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
- 5. Once submitted, responses are final, so ensure you’re confident in your answers.
- 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.
All Problems
Question
Action
What is recursion in JavaScript?
What is the purpose of a base case in recursion?
What will happen if a recursive function doesn't have a base case?
What will the following recursive function output?
What is the base case in the following recursive function?
How many recursive calls will be made when factorial(4) is executed using this function?
What will be the result of calling sum(5) for the following recursive function?
Which of the following best describes tail recursion?
What will the following recursive function return?
What is the termination condition in this Fibonacci recursive function?
What is recursion in JavaScript?
What is the purpose of a base case in recursion?
What will happen if a recursive function doesn't have a base case?
What will the following recursive function output?
function countDown(n) { if (n <= 0) { console.log("Done"); } else { console.log(n); countDown(n - 1); } } countDown(3);
What is the base case in the following recursive function?
function factorial(n) { if (n === 0) { return 1; } else { return n * factorial(n - 1); } }
How many recursive calls will be made when factorial(4) is executed using this function?
function factorial(n) { if (n === 0) { return 1; } else { return n * factorial(n - 1); } }
What will be the result of calling sum(5) for the following recursive function?
function sum(n) { if (n === 1) { return 1; } else { return n + sum(n - 1); } }
Which of the following best describes tail recursion?
What will the following recursive function return?
function power(base, exp) { if (exp === 0) { return 1; } else { return base * power(base, exp - 1); } } power(2, 3);
What is the termination condition in this Fibonacci recursive function?
function fibonacci(n) { if (n <= 1) { return n; } else { return fibonacci(n - 1) + fibonacci(n - 2); } }