## Zig-Zag traversal of a Binary Tree using Recursion

Given a Binary Tree, the task is to print the zigzag order of the tree. Examples: Input : 7 / \ 6 5 / /… Read More »

## Generate a random permutation of elements from range [L, R] (Divide and Conquer)

Given a range [L, R] where L ≤ R, the task is to generate a random permutation of the sequence [L, L + 1, L… Read More »

## Difference between Recursion and Iteration

A program is called recursive when an entity calls itself. A program is call iterative when there is a loop (or repetition). Example: Program to… Read More »

## Product of the alternate nodes of linked list

Given a linked list, the task is to print the product of alternate nodes of the given linked list. Examples: Input : 1 -> 8… Read More »

## Sum of the alternate nodes of linked list

Given a linked list, the task is to print the sum of the alternate nodes of the linked list. Examples: Input : 1 -> 8… Read More »

## Perform the given queries on the rooted tree

Given a rooted tree and not necessarily binary. The tree contains N nodes, labeled 1 to N. You are given the tree in the form… Read More »

## Next greater Number than N with the same quantity of digits A and B

Given a number and two digits and . The task is to find the least number not less than N which contains the equal number… Read More »

## Ways to write N as sum of two or more positive integers | Set-2

Given a number N, the task is to find the number of ways N can be partitioned, i.e. the number of ways that N can… Read More »

## Find nth term of a given recurrence relation

Let an be a sequence of numbers, which is defined by the recurrence relation a1=1 and an+1/an=2n. The task is to to find the value… Read More »

## Count all pairs of adjacent nodes whose XOR is an odd number

Given a Binary Tree as shown below. The task is to count all pair of adjacent nodes whose XOR is an odd number. Explanation: Initially,… Read More »

## 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 »