Posts that are related to Recursion.

## Check if linked list is sorted (Iterative and Recursive)

Given a Linked List, task is to check whether the Linked List is sorted in Descending order or not? Examples : Input : 8 ->… Read More »

## Reversing a queue using recursion

Given a queue, write a recursive function to reverse it. Standard operations allowed : enqueue(x) : Add an item x to rear of queue. dequeue()… Read More »

## Print all sequences starting with n and consecutive difference limited to k

Given three positive integer n, s and k. The task is to print all possible sequence of length s, starting with n and the absolute… Read More »

## Equal sum array partition excluding a given element

Given an array arr[] and an index in it. Find whether the array arr[] can be partitioned into two disjoint sets such that sum of… Read More »

## Delete middle element of a stack

Given a stack with push(), pop(), empty() operations, delete middle of it without using any additional data structure. Input : Stack[] = [1, 2, 3,… Read More »

## Recursive Practice Problems with Solutions

Basics – Recursion Recursive Functions Tail Recursion Strings – Given a string, print all possible palindromic partitions Check if a number is Palindrome Print all… Read More »

## Function to copy string (Iterative and Recursive)

Given two strings, copy one string to other using recursion. We basically need to write our own recursive version of strcpy in C/C++ Examples: Input… Read More »

## Find middle of singly linked list Recursively

Given a singly linked list and the task is to find middle of linked list. Examples: Input : 1->2->3->4->5 Output : 3 Input : 1->2->3->4->5->6… Read More »

## Time Complexity Analysis | Tower Of Hanoi (Recursion)

Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire… Read More »

## Partition given string in such manner that i’th substring is sum of (i-1)’th and (i-2)’th substring

Partition given string in such manner that i’th substring is sum of (i-1)’th and (i-2)’nd substring. Examples: Input : “11235813” Output : [“1”, “1”, “2”,… Read More »

## N Queen in O(n) space

Given n, of a n x n chessboard, find the proper placement of queens on chessboard. Previous Approach : N Queen Recommended: Please try your… Read More »

## Leaf nodes from Preorder of a Binary Search Tree (Using Recursion)

Given Preorder traversal of a Binary Search Tree. Then the task is print leaf nodes of the Binary Search Tree from the given preorder. Examples… Read More »

## Recursive program for prime number

Given a number n, check whether it’s prime number or not using recursion. Examples: Input : n = 11 Output : Yes Input : n… Read More »

## Recursive approach for alternating split of Linked List

Given a linked list, split the linked list into two with alternate nodes. Examples: Input : 1 2 3 4 5 6 7 Output :… Read More »