Author: SJ

10

Introduction To Dynamic Programming – Fibonacci Series

What is Dynamic Programming: Dynamic programming is a technique to solve the recursive problems in more efficient manner. Many times in recursion we solve the sub-problems repeatedly. In dynamic programming we store the solution...

3

Merge K Sorted Arrays

Objective: Given k sorted array, write an algorithm to merge Them into One sorted array. Example : int[][] A = new int[5][]; A[0] = new int[] { 1, 5, 8, 9 }; A[1] =...

0

Find the Deepest Left Node in a Binary Tree.

Objective: – Given a binary tree, Find the deepest left node in it. Approach: This approach is very similar to “Find the Deepest Node in a Binary Tree” with little modification. Take two global...

2

Find a Number occurring odd number of times in a Given array

Objective: Given a array of integers, in which every elements occurs even number of times except one number which occurs add number of times. Find out that number. Example:   int[] A = {...

0

Rearrange the Array of Given Range N, such that A[i]=i

Algorithms – Rearrange the Array of Given Range N, such that A[i]=i. Objective: Given a array of length N, in which elements are in the range of 1 to N. All elements may not...

0

Find a Missing Number From a Sequence of Consecutive Numbers | XOR Method

Input:  Array, arrA[] with a miss­ing num­ber and Range Out­put : miss­ing number Example: int A[] = { 1, 2, 7, 6, 3, 4 }; int range = 7; Output: MIssing No is :5 In...

4

Find the Max element in a Given Binary Tree

Objective: – Given a binary tree , Find the max element in it. Example: Approach: Use Recursion. Max will the Max(root, max element in left subtree, max element in rightsubtree) Recursively solve for max...

1

Populate Next Siblings Pointers in a Given Binary Tree OR Populate Next Right Pointers in Each Node

Objective: – Given a binary tree with three pointers left, right and nextSibling). Write the program to provide the nextsibling pointers. This problem can also be referred as “Populating Next Right Pointers in Each...

2

Print All Paths From Root In a Binary Tree Whose Sum is Equal to a Given Number

Objective: – Given a binary tree and X, write an algorithm to Print all the paths starting from root so that sum of all the nodes in path equals to a given number. Example:

2

Diameter Of a Binary Tree

Objective: – Given a binary tree, write an algorithm to find the diameter of the tree. What is Diameter Of a Tree: Diameter of tree is defined as A longest path or route between...

5

Find the Deepest Node in a Binary Tree.

Objective: – Given a binary tree, write an algorithm to Find the deepest node in it. Approach: Take two global variable as “deepestlevel” and “value“. starting with level=0, Do the inorder traversal and whenever...

0

Print All The Full Nodes in a Binary Tree

Objective: Given a binary tree, print all nodes will are full nodes. Full Nodes: Nodes Which has both the children, left and right are called Full Nodes Approach: quite simple Solution. Do the any...

%d bloggers like this: