DEV Community

Nozibul Islam
Nozibul Islam

Posted on

DSA: Recursion - Expanded Questions

DSA: Recursion - Expanded Questions.

1. Basic Recursion

  • Calculate the Factorial of a Number
  • Compute the Fibonacci Sequence
  • Calculate the Power of a Number (Exponentiation)
  • Print Numbers from 1 to N
  • Print Numbers from N to 1
  • Find the Sum of Natural Numbers up to N
  • Calculate the GCD (Greatest Common Divisor) of Two Numbers
  • Check if a String is a Palindrome
  • Find the nth Triangular Number
  • Count the Number of Digits in a Number

2. Recursion on Arrays and Lists

  • Find the Maximum Element in an Array
  • Find the Minimum Element in an Array
  • Sum of All Elements in an Array
  • Find the Index of a Target Element in a Sorted Array (Binary Search)
  • Count Occurrences of a Target Element in an Array
  • Reverse an Array
  • Merge Two Sorted Arrays
  • Find the Subsets of an Array
  • Generate Permutations of an Array
  • Generate Combinations of an Array

3. Recursion on Strings

  • Print All Substrings of a String
  • Generate All Permutations of a String
  • Generate All Combinations of a String
  • Find All Palindromic Substrings in a String
  • Implement String Compression
  • Find the Longest Palindromic Subsequence
  • Find the Minimum Number of Palindromic Partitions
  • Check if a String Matches a Pattern with Wildcards
  • Remove All Adjacent Duplicates from a String
  • Convert a String to an Integer (String to Integer Conversion)

4. Recursion in Trees

  • Traverse a Binary Tree (In-order, Preorder, Post-order)
  • Calculate the Height of a Binary Tree
  • Find the Maximum Depth of a Binary Tree
  • Check if a Binary Tree is Balanced
  • Count the Number of Nodes in a Binary Tree
  • Find the Lowest Common Ancestor of Two Nodes
  • Find All Paths from Root to Leaf in a Binary Tree
  • Convert a Binary Search Tree to a Doubly Linked List
  • Check if Two Trees are Identical
  • Find the Diameter of a Binary Tree

5. Recursion in Graphs

  • Perform Depth-First Search (DFS) on a Graph
  • Perform Breadth-First Search (BFS) Using Recursion
  • Find All Connected Components in a Graph
  • Detect a Cycle in a Graph Using DFS
  • Find the Shortest Path in a Graph Using DFS
  • Solve the N-Queens Problem
  • Solve the Rat in a Maze Problem
  • Find All Hamiltonian Paths in a Graph
  • Find All Eulerian Paths in a Graph
  • Solve the Subset Sum Problem
  • Additional Questions on Recursion

6. Advanced Recursion Techniques

  • Solve the Tower of Hanoi Problem
  • Implement Merge Sort Using Recursion
  • Implement Quick Sort Using Recursion
  • Solve the Josephus Problem
  • Find the Number of Ways to Climb Stairs with Steps of 1 or 2
  • Generate All Unique Subsets of a Set
  • Find the All Possible Expressions that Evaluate to a Target
  • Solve the Coin Change Problem
  • Find the Maximum Subarray Sum Using Recursion
  • Find the Longest Increasing Subsequence

7. Practical Applications of Recursion

  • Implement a Recursive Backtracking Algorithm for Sudoku Solver
  • Solve the Maze Problem with Backtracking
  • Create a Recursive Function for File System Traversal
  • Implement a Recursive Function to Generate All Possible IP Addresses
  • Solve the K-Coloring Problem Using Backtracking
  • Implement Recursive Depth Calculation for Nested Structures (like JSON)
  • Build a Recursive Function for Directory Listing
  • Design a Recursive Search Algorithm for a Game Board
  • Use Recursion to Solve the Word Search Puzzle
  • Implement Recursive Functionality for Parsing Nested Lists

πŸ”— Connect with me on LinkedIn:

I regularly share insights on JavaScript, Node.js, React, Next.js, software engineering, data structures, algorithms, and more. Let’s connect, learn, and grow together!

Follow me: Nozibul Islam

Top comments (0)