Skip to content

updated recursion.py#10

Open
GHANATHAY-JANVI wants to merge 4 commits intomuskankhedia:mainfrom
GHANATHAY-JANVI:main
Open

updated recursion.py#10
GHANATHAY-JANVI wants to merge 4 commits intomuskankhedia:mainfrom
GHANATHAY-JANVI:main

Conversation

@GHANATHAY-JANVI
Copy link

This PR implements two recursive algorithms in the Recursion Algorithms Module:

Recursive Palindrome Check

Tower of Hanoi Solver

🔹 1. is_palindrome_recursive

Implements palindrome checking using recursion.

Uses base case when string length is 0 or 1.

Recursively compares first and last characters.

Time Complexity: O(n)

Space Complexity: O(n) (due to recursion stack)

🔹 2. tower_of_hanoi

Implements the classic Tower of Hanoi recursive solution.

Follows standard recursive strategy:

Move n-1 disks to auxiliary

Move largest disk to destination

Move n-1 disks to destination

Returns list of move steps.

Time Complexity: O(2^n)

This PR implements two recursive algorithms in the Recursion Algorithms Module:

Recursive Palindrome Check

Tower of Hanoi Solver

🔹 1. is_palindrome_recursive

Implements palindrome checking using recursion.

Uses base case when string length is 0 or 1.

Recursively compares first and last characters.

Time Complexity: O(n)

Space Complexity: O(n) (due to recursion stack)

🔹 2. tower_of_hanoi

Implements the classic Tower of Hanoi recursive solution.

Follows standard recursive strategy:

Move n-1 disks to auxiliary

Move largest disk to destination

Move n-1 disks to destination

Returns list of move steps.

Time Complexity: O(2^n)
@muskankhedia
Copy link
Owner

Please resolve the merge conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants