## Sum of the nodes of a Singly Linked List

Given a singly linked list. The task is to find the sum of nodes of the given linked list. Task is to do A +… Read More »

## Check if two trees have same structure

Given two binary trees. The task is to write a program to check if the two trees are identical in structure. In the above figure… Read More »

## Water Jug Problem using Memoization

Given two jugs with the maximum capacity of m and n liters respectively. The jugs don’t have markings on them which can help us to… Read More »

## Reduce a number to 1 by performing given operations

Given a number N. The task is to reduce the given number N to 1 in the minimum number of steps. You can perform any… Read More »

## Print all the combinations of a string in lexicographical order

Given a string str, print of all the combinations of a string in lexicographical order. Examples: Input: str = “ABC” Output: A AB ABC AC… Read More »

## Number of ways to represent a number as sum of k fibonacci numbers

Given two numbers N and K. Find the number of ways to represent N as the sum of K Fibonacci numbers. Examples: Input : n… Read More »

## Recursive program to print formula for GCD of n integers

Given a function gcd(a, b) to find GCD (Greatest Common Divisor) of two number. It is also known that GCD of three elements can be… Read More »

## Perform n steps to convert every digit of a number in the format [count][digit]

Given a number num as a string and a number N. The task is to write a program which converts the given number num to… Read More »

## Print all possible ways to convert one string into another string | Edit-Distance

Prerequisite: Dynamic Programming | Set 5 (Edit Distance) Given two strings str1 and str2, the task is to print the all possible ways to convert… Read More »

## Level order traversal with direction change after every two levels | Recursive Approach

Given a binary tree, print the level order traversal in such a way that first two levels are printed from left to right, next two… Read More »

## Sudo Placement | Special Subsequences

Given a non-empty string S containing only lowercase letters, print all ‘Special Subsequences’ of S. For Instance, “ab” has the following Special Subsequences-: { “A”,… Read More »

## Number of sequences which has HEAD at alternate positions to the right of the first HEAD

Given that a coin is tossed N times. The task is to find the total number of the sequence of tosses such that after the… Read More »

## Compute power of power k times % m

Given x, k and m. Compute (xxxx…k)%m, x is in power k times. Given x is always prime and m is greater than x. Examples:… Read More »

## Algorithms | Recursion | Question 9

filter_none edit close play_arrow link brightness_4 code #include<stdio.h> void crazy(int n,int a,int b) {     if (n <= 0)  return;     crazy(n-1, a, b+n);     printf(“%d %d %d\n”,n,a,b);… Read More »

## Algorithms | Recursion | Question 8

Predict the output of following program filter_none edit close play_arrow link brightness_4 code #include <stdio.h> int f(int n) {     if(n <= 1)         return 1;     if(n%2… Read More »