# Tag Archives: tail-recursion

## Sum of series formed by difference between product and sum of N natural numbers

Given a natural number N, the task is to find the sum of the series up to Nth term where the ith term denotes the… Read More »

## Check if a given number is a Perfect square using Binary Search

Check if a given number N is a perfect square or not. If yes then return the number of which it is a perfect square,… Read More »

## Divide an array into K subarray with the given condition

Given an array arr[] and an integer K. The task is to divide the array into K parts ( subarray ) such that the sum… Read More »

## Counts Path in an Array

Given an array A consisting of positive integer, of size N. If the element in the array at index i is K then you can… Read More »

## Maximum number of given operations to remove the entire string

Given a string str containing lowercase English characters, we can perform the following two operations on the given string: Remove the entire string. Remove a… Read More »

## Python | Handling recursion limit

When you execute a recursive function in Python on a large input ( > 10^4), you might encounter a “maximum recursion depth exceeded error”. This… Read More »

## Number of ways in which an item returns back to its initial position in N swaps in array of size K

Given two numbers K and N, the task is to find the number of ways such that an item at position i returns back to… Read More »

## Check whether two strings are equivalent or not according to given condition

Given two strings A and B of equal size. Two strings are equivalent either of the following conditions hold true: 1) They both are equal.… Read More »

## Recursive program to print all numbers less than N which consist of digits 1 or 3 only

Given an integer N, the task is to print all the numbers ≤ N which have their digits as only 1 or 3. Examples: Input:… Read More »

## Recursive program to insert a star between pair of identical characters

Given a string with repeated characters, we have to insert a star i.e.” * “ between pair of adjacent identical characters using recursion. Examples: Input… Read More »

## Check if item can be measured using a scale and some weights

Given some weights of masses a0, a1, a2, …, a100, a being an integer, and a weighing scale where weights can be put on both… Read More »

## Number of ways to divide a given number as a set of integers in decreasing order

Given two numbers and . The task is to find the number of ways in which a can be represented by a set such that… Read More »

## Tail recursion to calculate sum of array elements.

Given an array A[], we need to find the sum of its elements using Tail Recursion Method. We generally want to achieve tail recursion (a… 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 »

## Tail Recursion for Fibonacci

Write a tail recursive function for calculating the n-th Fibonacci number. Examples : Input : n = 4 Output : fib(4) = 3 Input :… Read More »