Skip to content

Category Archives: Recursion

Explain the functionality of the following functions.  Question 1  C++ int fun1(int x, int y) {     if (x == 0)         return y;     else         return fun1(x… 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
Assume the structure of a Linked List node is as follows.  C++ struct Node {   int data;   struct Node *next; };   // This code… Read More
Given a Binary Tree, the task is to print the Level order traversal of the Binary Tree in spiral form i.e, alternate order. Example: Input:Output:… Read More
Given a string S, the task is to write a program to print all permutations of a given string.  A permutation also called an “arrangement… Read More
Write a program to reverse the digits of an integer. Examples :   Input : num = 12345 Output: 54321 Input : num = 876 Output:… Read More
Given an array A[] of n numbers and another number x, the task is to check whether or not there exist two elements in A[]… Read More
Given a number, find the sum of its digits. Examples :  Input: n = 687Output: 21 Input: n = 12Output: 3 Recommended Practice Sum Of… Read More
If we take a look at this problem carefully, we can see that the idea of “loop” is to track some counter value, e.g., “i… Read More

Start Your Coding Journey Now!