# Category Archives: Recursion

Given two integers N and K (K<N), the task is to find the smallest number greater than K by removing digits from N. Note: Youâ€¦ Read More
Write a program to reverse a stack using recursion, without using any loop. Example:Â  Input: elements present in stack from top to bottom 1 2â€¦ Read More
Given an integer matrix mat[][] of size M x N and an integer K, the task is to return the number of paths from top-leftâ€¦ Read More
Given two numbers N and K, and a pair A and B, the task is to multiply N by A or B as many timesâ€¦ Read More
Given a tree with N nodes, an array A[] of size N denoting the value of each node and array edges [][] of size (N-1),â€¦ Read More
Given 2 arrays num[] and cost[] containing the number of elements and the cost to buy that many elements respectively. {i.e. cost[i] is the costâ€¦ Read More
Given a binary tree and an integer K, the task is to write a program to count the number of nodes such that the pathâ€¦ Read More
Given a binary tree and a node start that is initially infected. For every second, neighbours of an infected node get infected. The task isâ€¦ Read More
Given N nodes, where each of them is numbered from 0 to N – 1, and array edges, where there is a directed edge fromâ€¦ Read More
These are the special type of recursive functions, where the last statement executed inside the function is the call to the function itself. Advantages ofâ€¦ Read More
Given a 2-D array A[][] of size NÃ—3, where each element of the array consists of {x, y, r}, where x and y are coordinatesâ€¦ Read More
Given a Binary Search Tree, The task is to print the elements in inorder, preorder, and postorder traversal of the Binary Search Tree.  Input:  Aâ€¦ Read More
Given an array arr[] of size N and a given difference diff, the task is to count the number of partitions that we can performâ€¦ Read More
Given a positive integer N, the task is to find the number of distinct ways to express N as a sum of positive palindromic integersâ€¦ Read More
Given an array A[] of positive integers, print all the unique non-empty subsets of the array  Note: The set can not contain duplicate elements, soâ€¦ Read More