Monday, October 22, 2012

National Instruments Interview of Monika Bisla

Written:


  • sqrt(b^2 - 4ac), if a =[0, 0.5] and b=[4, infinity), Whats the range of c?
  • Write a recursive function to get the product of all the digits of a number.(eg: for 123: output 1*2*3; for 56: output 5*6=30)
  • Find the 100th number of the series 2, 4, 8, 14, 22, 32....
  • Find the 20,000th element of the series 1, 2,2, 3,3,3, 4,4,4,4, ....
  • Write a single statement to check whether a given number is a power of 2.
  • T(n) = 2*T(n-1)+2^(n-1); T(1) = 1. Find T(7).

  •  int index, i=0, k=0, j=0;  
     for(index=0; index <= some_number; index++){  
       i = i+1;  
       if( (i/5) == 1 ){  
         i=0;  
         k = k+1;  
         if( (k/5) == 1){  
           k=0;  
           j = j+1;  
         }  
       }  
     }  
    

    What's the value of i, k, j interms of 'some_number' after the the execution of for loop?
  • A bag contains 3 coins out of which * 1 coin is painted RED both the sides * 1 coin is painted BLUE both the sides* 1 coin is painted RED with one side and BLUE with another. Two coins are selected from the bag and tossed. Find the probability of  getting both as RED.
  • What's the effect of(or write a common code) the following code on an array of 8 elements?
     for(i=0; i<4; i++)  
       a[i] += a[i+4];  
     for(i=0; i<4; i++)  
       a[i] += a[i+2];  
     for(i=0; i<4; i++)  
       a[i] += a[i+1];  
    
  • Write a function for generating random number between a given range.
    Using above, write a function to generate random integers between a given range such that probability of each integer is same.
  • How many edges are there in a complete graph of n vertices.
    Using the formula in question above, find number of graphs possible with ‘n’ vertices (graphs need not to be complete).
  • Calculate number of inversions in a given array.
    In general what would be the number of inversions in the worst case and what is that worst case.
  • Let us define a walk from v to v in the given graph:

    Number of 1-walk is represented by W(1) and given by:
            V-V                               // W(1) = 1
    Number of 2-walk is represented by W(2) and given by:
            V-V-V
            V-W-V                           //W(2) = 2
    Find W(3) and W(4).
    Also find W(n) in general.
  • Draw a DFA for a language which ends with 0101.
Interview 1:
In this interview, they basically discussed written test only and some extra questions:
  • Write code for making a copy of Binary Tree.
  • Write code for finding maximum root to leaf path sum.
    Write code for both approaches (top-down and bottom-up).
Interview 2:
  • Given a long formula for a carbon compound, Write a code for counting the number of carbon atoms.
    Ex: (C2H6(CH2)6CH2C3H4)4CH2C6H6C5H5
    Handle all the cases.
    Give code for iterative as well as recursive approach.
  • Given a Binary tree, where internal nodes of the tree represents an AND or an OR gate and leaf nodes consists of values either 0 or 1.
    Write code for finding the final resultant at the root node.
  • In the Question given above, add one more argument to your function which gives the expected value of the result.
    If result calculated by your function and expected values are not same, flip the gates in internal nodes of tree in such a manner such that result and expected values comes out to be equal.
    Do this in minimum number of flips possible.
    Also handle those cases where it is impossible to achieve the expected value.
    Write the code for above problem.
Then, there were some normal HR questions and that was it!! 

No comments:

Post a Comment