0% found this document useful (0 votes)
22 views2 pages

Recursion Exam

The document outlines a series of recursive programming challenges categorized into beginner, intermediate, advanced, and expert levels. Each category includes specific tasks such as calculating factorials, checking palindromes, solving the N-Queens problem, and implementing the Ackermann function. Additionally, it features special categories focusing on tree problems, mathematical problems, and string manipulation.

Uploaded by

sreekantha reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Recursion Exam

The document outlines a series of recursive programming challenges categorized into beginner, intermediate, advanced, and expert levels. Each category includes specific tasks such as calculating factorials, checking palindromes, solving the N-Queens problem, and implementing the Ackermann function. Additionally, it features special categories focusing on tree problems, mathematical problems, and string manipulation.

Uploaded by

sreekantha reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Beginner Level (Understanding Base Cases and Simple Recursion)

1. Factorial Calculation
Write a recursive function to compute the factorial of a number n (n! = n × (n − 1) × · · · × 1)
2. Sum of Digits
Create a function that recursively calculates the sum of digits of a positive integer (e.g., sum digits(123) → 6)
3. Count Down
Implement a recursive countdown from n to 1 that prints each number
4. Power Function
Write a recursive function to calculate x raised to the power y (xy )
5. Fibonacci Sequence
Implement the Fibonacci sequence recursively (fib(0) = 0, fib(1) = 1, fib(n) = fib(n − 1) + fib(n − 2))

Intermediate Level (More Complex Recursive Patterns)


6. Palindrome Check
Recursively determine if a string is a palindrome

7. Binary Search
Implement binary search recursively on a sorted array
8. GCD Calculation
Write a recursive function to find the greatest common divisor (GCD) of two numbers using Euclid’s algorithm

9. Tower of Hanoi
Solve the Tower of Hanoi problem recursively for n disks
10. Linked List Traversal
Write recursive functions to: (a) print all elements, (b) reverse a linked list

Advanced Level (Complex Recursive Problem Solving)


11. Subset Generation
Generate all possible subsets of a set (power set) recursively
12. Permutations
Write a recursive function to generate all permutations of a string
13. Flood Fill Algorithm
Implement the flood fill algorithm recursively (like the paint bucket tool)
14. N-Queens Problem
Solve the N-Queens puzzle using backtracking recursion
15. Sudoku Solver
Create a recursive backtracking solution to solve Sudoku puzzles

Expert Level (Challenging Recursive Problems)


16. Ackermann Function
Implement the Ackermann function (a classic example of non-primitive recursion)
17. Recursive Descent Parser
Build a simple arithmetic expression evaluator using recursive descent parsing

1
18. Koch Snowflake
Generate Koch snowflake fractal patterns using recursion
19. Memoization Optimization
Take a naive recursive Fibonacci implementation and optimize it with memoization
20. Mutual Recursion
Implement the Hofstadter Female and Male sequences using mutual recursion

Special Categories
Tree Problems (Natural Recursion Domain)
21. Tree Depth
Calculate the maximum depth of a binary tree recursively

22. Tree Mirroring


Write a function to mirror a binary tree (swap all left/right children)
23. Path Sum
Find if a binary tree has a root-to-leaf path that sums to a target value

24. Lowest Common Ancestor


Find the lowest common ancestor of two nodes in a binary tree

Mathematical Problems
25. Digital Root
Compute the digital root (recursive sum until single digit) of a number
26. Pascal’s Triangle
Generate Pascal’s triangle recursively and find specific values

27. Combination Calculation


Calculate combinations C(n, k) recursively using Pascal’s identity

String Manipulation
28. String Permutations
Generate all unique permutations of a string with duplicate characters
29. Generate Parentheses
Generate all valid combinations of n pairs of parentheses
30. Wildcard Matching
Implement a simple wildcard pattern matching with ’ ?’ and ’*’ using recursion

You might also like