Recursion is a technique that leads to elegant solutions to problems that are difficult to program using simple loops. Recursion is an alternative form of program control. It is essentially repetition without a loop.
Requirements:
- A Java development environment (e.g., IntelliJ IDEA, Eclipse)
2.A GitHub account
Instructions:
-
Clone the repo files to your local machine.
-
Create a Java class named Recursion, and implement one of the following cases:
a. fibonacci(n): Calculates the nth Fibonacci number.
b. power(x, n): Calculates the power of a number x raised to a non-negative integer n.
c. reverseString(str): Reverses a given string str.
d. palindrome(str): Checks whether a given string str is a palindrome.
e. Write a recursive method named countDown that takes an integer parameter and prints a countdown from that number to 1, test your countDown method with different input values.
f.Write a recursive method named binarySearch that performs a binary search on a sorted array.
g. Using a recursive method, find a path through a maze from the start to the end. Recursive solution involves exploring each possible move until a solution is found.
H. Implement** Merge Sort Function ** using recursion approach.
I. N-Queens problem, or Sudoku solving solving using recursion approach.
J. Reverse a **Linked List ** using recursive funciton.
K. Travel Traversal: using a recursive function, traverse through the nodes of a Tree data structure. Recursive solution include in-order, pre-order, and post-order traversals.
3.For each method, write a unit test case to verify its correctness.
-
Commit and push your changes to the GitHub repository.
-
Optional Task - Implement another version of your method using an iterative (normal loop) approach and compare its efficiency to the recursion version.