- Task 1: Write a recursive function to calculate the factorial of a number. Log the result for a few test cases.
- Task 2: Write a recursive function to calculate the nth Fibonacci number. Log the result for a few test cases.
- Task 3: Write a recursive function to find the sum of all elements in an array. Log the result for a few test cases.
- Task 4: Write a recursive function to find the maximum element in an array. Log the result for a few test cases.
- Task 5: Write a recursive function to reverse a string. Log the result for a few test cases.
- Task 6: Write a recursive function to check if a string is a palindrome. Log the result for a few test cases.
- Task 7: Write a recursive function to perform a binary search on a sorted array. Log the index of the target element for a few test cases.
- Task 8: Write a recursive function to count the occurrences of a target element in an array. Log the result for a few test cases.
- Task 9: Write a recursive function to perform an in-order traversal of a binary tree. Log the nodes as they are visited.
- Task 10: Write a recursive function to calculate the depth of a binary tree. Log the result for a few test cases.
- Factorial and Fibonacci Script: Write a script that includes recursive functions to calculate the factorial and Fibonacci numbers.
- Array Recursion Script: Create a script that includes recursive functions to find the sum and maximum element of an array.
- String Recursion Script: Write a script that includes recursive functions to reverse a string and check if a string is a palindrome.
- Recursive Search Script: Create a script that includes recursive functions for binary search and counting occurrences in an array.
- Tree Traversal Script: Write a script that includes recursive functions for in-order traversal and depth calculation of a binary tree (optional).
By the end of these activities, students will:
- Understand and implement basic recursion.
- Apply recursion to solve problems with arrays and strings.
- Use recursion for searching and counting elements in arrays.
- Perform traversal and calculate tree depth using recursion (optional).