DEV Community

Jayaprasanna Roddam
Jayaprasanna Roddam

Posted on • Edited on

DSA: Recursion - 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

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay