Posts that are related to Recursion.

Minimize the sum after choosing elements from the given three arrays

Given three arrays A[], B[] and C[] of same size N. The task is to minimize the sum after choosing N elements from these array… Read More »

Maximise array sum after taking non-overlapping sub-arrays of length K

Given an integer array arr[] of length N and an integer K, the task is to select some non-overlapping sub-arrays such that each sub-array is… Read More »

Paths from entry to exit in matrix and maximum path sum

Given a maze which is a N * N grid grid[][]. Every cell of the maze contains either the number 1, 2 or 3 which… Read More »

Factorial of an Array of integers

Given an array with positive integers. The task is to find the factorial of all the array elements. Note: As the numbers would be very… Read More »

Find maximum topics to prepare in order to pass the exam

Given three integer n, h and p where n is the number of topics, h is the time left (in hours) and p is the… Read More »

Algorithms Sample Questions | Set 3 | Time Order Analysis

Question 1: What is the asymptotic boundary of T(n)? θ( n*log(n) ) θ( n2 ) θ( n ) θ( n*log2(n) ) θ( n2*log2(n) ) Answer:… Read More »

Program to Calculate e^x by Recursion

The value of Exponential function can be calculated using Taylor Series. = 1 + x/1! + /2! + /3! + …… To find its value… Read More »

Algorithms Sample Questions | Recurrences | Set 2

Question 1: What is the complexity of T(n)? Θ( 1⁄n ) Θ( 1⁄n2 ) Θ( 1 ) Θ( ln( n ) ) Answer: 3 Explanation:… Read More »

Number of subsets with zero sum

Given an array ‘arr’ consisting of integers, the task is to find the number of subsets such that their sum is equal to zero. Empty… Read More »

Sum of maximum of all subarrays | Divide and Conquer

Given an array arr[] of length N, the task is to find the sum of the maximum elements of every possible sub-array of the array.… Read More »

Maximum sum in an array such that every element has exactly one adjacent element to it

Given an array arr[] of N integers, you can select some indexes such that every selected index has exactly one other selected index adjacent to… Read More »

Generate all unique partitions of an integer | Set 2

Given a positive integer n, the task is to generate all possible unique ways to represent n as sum of positive integers. Examples: Input: 4… Read More »

Number of ways to reach the end of matrix with non-zero AND value

Given an N * N matrix arr[][] consisting of non-negative integers, the task is to find the number of ways to reach arr[N – 1][N… Read More »

GCD from root to leaf path in an N-ary tree

Given an N-ary tree and an array val[] which stores the values associated with all the nodes. Also given are a leaf node X and… Read More »

Sum of the mirror image nodes of a complete binary tree in an inorder way

Given a complete binary tree, the task is to find the sum of mirror image nodes in an inorder way i.e. find the inorder traversal… Read More »