Dynamic Programming – Minimum Coin Change Problem

Objective: Given an amount of ‘A’ and n coins,   v1<v2<v3<………..<vn. Write a program to find out the minimum number of … Read more

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 variables as “deepestlevel” and “value”.
  • starting with level=0, Do the inorder traversal and whenever you go down one level ( root.left OR root.right), increase the level by 1.
  • Keep checking if deepestlevel < level, if yes then update the “deepestlevel ” and “value “.
  • At the end return “value”, which will be the deepest node value.
  • See the code for a better explanation.

Read more

Find numbers that are palindrome in the decimal and octal Representations

Objective: Given a range of integers, find all the numbers which are palindrome when they are represented in Decimal Value( base 10) and in Octal value(base 8).

Example :

Number : 373 (Decimal) and digits are palindrome.

Convert it into Octal which is 565 and that's also palindrome.

Approach:

Read more

Find All the Well Ordered Permutations of a Given String.

Objective: Write an algorithm to Print All the Well Ordered Permutations of a Given String.

What is Well Ordered String: When all the alphabets in a string occur in the increasing order irrespective of Lower Case or Upper case.

http://www.careercup.com/question?id=6206517812396032

Example :

"Sumit" - Not Well Ordered . 'u' occurred after 'S'.

"Now" - Well Ordered. N<o<W.

Input: Interview
Output: 
[e, e, I, i, n, r, t, v, w] [e, e, i, I, n, r, t, v, w] [e, e, i, I, n, r, t, v, w] [e, e, I, i, n, r, t, v, w]

Read more

Construct a Special Triangle from a Given Array

Objective: Given an array of integers such that first level will print all the elements in the array and from then at each level number of elements will be one less than the previous level and elements at the level will be the Sum of consecutive elements in the previous level. Print it in a reverse level. See Example.

Example:

Construct-a-Special-Triangle-from-a-Given-Array
Construct-a-Special-Triangle-from-a-Given-Array

Read more