## Finding the lexicographically smallest diameter in a binary tree

Given a binary tree where node values are lowercase alphabets, the task is to find the lexicographically smallest diameter. A diameter is the longest path… Read More »

## Bottom View of a Binary Tree using Recursion

Given a binary tree, the task is to find the bottom view of a binary tree using recursion. Examples: Input: 1 \ 2 \ 4… Read More »

## Find F(n) when F(i) and F(j) of a sequence are given

Given five integers i, Fi, j, Fj and N. Where Fi and Fj are the ith and jth term of a sequence which follows the… Read More »

## Recursion in Java

What is Recursion? The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called as recursive… Read More »

## Find maximum product of digits among numbers less than or equal to N

Given an integer N > 0, the task is to find the maximum product of digits among numbers less than or equal to N. Examples:… Read More »

## Recursion in Perl

Recursion is a mechanism when a function calls itself again and again till the required condition is met. When the function call statement is written… Read More »

## Program to unfold a folded linked list

A linked list L0 -> L1 -> L2 -> ….. -> LN can be folded as L0 -> LN -> L1 -> LN – 1… Read More »

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