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 will the following recursive function output?
What is mutual recursion?
Which problem does the following recursive function solve?
What will be the output of the following recursive function?
What is the result of calling isEven(10) using the following mutual recursive functions?
What will the following recursive function return?
Which of the following recursive functions will result in a stack overflow in JavaScript?
What will this recursive function output for fibonacci(6)?
How can recursion be optimized in some cases to avoid redundant calls?
What does the following recursive function compute?
What will the following recursive function output?
function reverseString(str) { if (str === "") { return ""; } else { return reverseString(str.substring(1)) + str[0]; } } console.log(reverseString("javascript"));
What is mutual recursion?
Which problem does the following recursive function solve?
function gcd(a, b) { if (b === 0) { return a; } else { return gcd(b, a % b); } } gcd(48, 18);
What will be the output of the following recursive function?
function sumOfDigits(n) { if (n === 0) { return 0; } else { return (n % 10) + sumOfDigits(Math.floor(n / 10)); } } console.log(sumOfDigits(456));
What is the result of calling isEven(10) using the following mutual recursive functions?
function isEven(n) { if (n === 0) return true; return isOdd(n - 1); } function isOdd(n) { if (n === 0) return false; return isEven(n - 1); }
What will the following recursive function return?
function multiply(a, b) { if (b === 0) { return 0; } else { return a + multiply(a, b - 1); } } multiply(4, 3);
Which of the following recursive functions will result in a stack overflow in JavaScript?
What will this recursive function output for fibonacci(6)?
function fibonacci(n) { if (n <= 1) { return n; } else { return fibonacci(n - 1) + fibonacci(n - 2); } }
How can recursion be optimized in some cases to avoid redundant calls?
What does the following recursive function compute?
function power(base, exp) { if (exp === 0) { return 1; } else { return base * power(base, exp - 1); } } power(2, 4);