Tuesday, 29 November 2011

# find the largest bst(binary search tree) in a binary tree

Given a binary tree find the largest binary search tree.

Saturday, 26 November 2011

what is endianess? write a pgm to detremine endianess

# Given a number, find the next number which is a palindrome.
# Given the number 'x' and an array print the pairs in the array where the sum is equal to the given number 'x'
# Find the maximum sum sub array
io [1,2,3]  op [1,2,3] sum = 6
io[-3,-4,-5,-89,-7,4]  op [4] sum = 4
io[45,-2,4,-10,-34] op[45,-2,4]

#Find the maximum product sub array

Thursday, 24 November 2011

# mirror effect of the tree.
Given the tree(as array or as reference) return the mirroring of the tree
# Common nearest Ancestor of two nodes in a tree
# Print all the common ancestors of two nodes

Wednesday, 23 November 2011


Find number which occurs n/2 times in an array
in O(n)
--- without using sort and hash
# Find the diameter of the tree

       9
      / \
     2   3
    / \
   1   3
  /  \
 1        7
            \
             8
here if we traverse like  1-1-2-9-3 length will be smaller
but if we traverse like    1-1-2-3-7-8 the length will be larger

so the diameter is 1-1-2-3-7-8.
# find the depth of the tree
# find the depth of the node in the tree

Tuesday, 22 November 2011

find the largest of three no. with out using the comparison operator
if(a/b == 0) then a is smaller than b or b is greater than a
else if(b/a == 0) then b is smaller than a or a is greater than b

eg 7/34 =0 so 34 is greater than 7
Implement a search function for a sorted rotated array. Duplicates are allowed. Returning any one of the duplicates is acceptable.
http://www.mytechinterviews.com/search-in-a-sorted-circular-array
You are given an array with integers (both positive and negative) in any random order. Find the sub-array with the largest sum.
http://www.mytechinterviews.com/sub-array-with-the-largest-sum

Sunday, 20 November 2011

Given a array of numbers we need to remove duplicates and arrange the distinct elements in the same order and rest of the array should be filled with 0, provided the repeating elements will be adjcent to each other
note: do not use extra spaces(do not use another array)

sample ip : 224444557   (ip will not be of this format : 242234, i.e. repeating ele will be adjcent to each other)
op : 245700000
# Permutation of the string
print the different combination of the input string
ip abc , op = abc, bca, cab

# Combination of the string
print the different combinations of the string
ip a,b,c op = a, b, c, ab, bc, ca, abc
here if the input has 3 output will be 7 which is
if the input is n output will be 2^n -1
because nC0+nC1+nC2+...+nCn

Saturday, 19 November 2011

print tree in a sprial way
anagram of a string
Find the intersection of the linked list which is of  "y" 
Find the loop in the linked list
Difference between the hash map, hash table and hash set
Hash table
It didn’t allow null for both key and value. You will get NullPointerException if you add null value.
It is synchronized. So it comes with its cost. Only one thread can access in one time

Hash map
It allows null for both key and value
It is unsynchronized. So come up with better performance

Hash set
HashSet does not allow duplicate values. It provides add method rather put method. You also use its contain method to check whether the object is already available in HashSet. HashSet can be used where you want to maintain a unique list.