Wednesday 6 January 2016

.net programs that frequently asked in interview


    1. Find the lowest common ancestor of given n nodes in given binary tree. Nodes are given in  array of size n.
    2. Generate the following pattern when x is given upto Nth terms
             For ex:
             Input: x=2 ,N=5
           
     OUTPUT:
             2
            12
          1112
          3112
        132112

    3. Find the next higher no. Of x Whose binary represent does not contain consecutive 1s-

       For ex:
       Input:
      12
      Output
      16

     4. Write a C program that, given an array A[] of n numbers and another number x, determines whether
    or not there exist two elements in S whose sum is exactly x.
    5. Write an efficient program for printing k largest elements in an array. Elements in array can be in any
    order.
    6. Given an unsorted array in which every adjacent element is differ by either +1 or -1
    Write an efficient code to find x where x is also given.
    7. Check if binary conversion of given number is palindrome or not. Ex: 6 (0110) is palindrome.
    8. Separate 0’s and 1’s in that order from a array of only 0’s and 1’s.
       (I used partition algorithm (Quick Sort) to do the same. O(n) time complexity.)
    9. One Sentence (string) is given. find out the words, that has length even and greater than equal to 4 (e.g. 4,6,8.. etc.) and separate them with space.
    e.g. Given String : “abcd abc abcde abcdef”
    Output: “ab cd abc abcde abc def”
    I allocated a new string dynamically, and used two for loops to copy one string to another, adding a space at the middle of the word where word length was >=4 and even. O(n^2) time complexity.
    It seems easy but it isn’t. I got to know that this can be minimized to O(n) time complexity in the next round.

    10. Find the longest palendrom in a string?
         Example
         Input: abfgerccdedccfgfer
         Output: ccdedcc
    11. Input an array and prints the second minimum in an array??
          Example
          Input:34,45,21,12,54,67,15
         Output:15
    12. An array contain 6 different numbers, only 1 number is repeated for 5 times. So now total 10 numbers in array, Find that duplicate number in 2 steps only?
    13. Write a program to print elements of a linked list in reverse order by using same single linked list?

    1 comment:

    1. some more questions : http://www.coding-interview.com/CodingInterview/hash-table/

      ReplyDelete

    Contact Us:

    Email:

    Vinodkumar434@gmail.com,
    vinodtechnosoft@gmail.com

    Skype Name:

    vinodtechnosoft