Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Interview Questions

Q) You are given a boolean matrix of m*n dimension. It contains 1s and 0s filled at random location. Now, you have to do the following transformation. for all a[i][j]=1 do for k from 1 to n a[i][k]=1 for k from 1 to m a[k][j]=1 In short, this means that if there is 1 at some location in the initial matrix, then that row and column should be filled with 1. Please do not use O(m*n) extra space. [Amazon-Intern] Q) You have to make the function isBst which takes the root node of a binary tree as argument and returns true if the tree is a binary search tree. [Amazon-Intern] Q) There is an array of size n. It contains elements in the range from 1 to n only. But some elements may occur more than once, and some elements may not occur even once. You have to find all the repeated elements without using extra space.You can use only O(1) extra space. [Amazon-Intern] Q) Given a binary tree, you have to write the code for level order traversal of the tree, such that each level is printed, then a , is printed as shown below. 1, 2 3, 4 5 6 7, ..... and so on. Note: It is not necessary that the tree is a complete binary tree or almost complete binary tree. [Amazon-Intern] Q) What does the keyword volatile stands for? [Amazon-Intern] Q) There is a building with 100 floors. You are given two identical eggs. You have to find the minimum floor from which the eggs when thrown down will break. [Amazon-Intern]

Q) Write a perfectly working production code to find the square root of a perfect square.

[Amazon] Q) Given a binary tree, convert it into a double linked list. [Amazon] Q) You are given a 2*2 matrix with its element as follows. |a b| |d c | This is zoom level 1 for the matrix. Now when you zoom to level 2, you have the following matrix. |aa ab ba bb| |ad ac bd bc| |da db ca cb| |dd dc cd cc| When you zoom to level 3, you will have an 8*8 matrix, some of its elements as follows: |aaa aab aba abb ....... | |aad aac abd abc ........ | |ada adb aca acb ........ | |add adc acd acc .........| | | ... | | Like this, there are infinite zoom levels. Given a string, you have to find the string which will be to left of it. eg: the string to left of aab is aaa to left of aba is aab In case if it is leftmost string, just return null Now generalise it for all, ie. to strings that are to right, up, down.. [Amazon] Q) Given two sorted arrays of integers, and an integer n, you have to find i,j such that a[i]+b[j]<=n and a[i]+b[j] is as large as possible. [Amazon] Q) Given two binary trees, you have to return -1 if tree1 < tree2 0 if tree1 = tree2 1 if tree1 > tree2

The comparison of trees is based on the following. When inorder traversal of a tree is done, then we get a string. Now tree1 is smaller than tree2 if the inorder traversal of tree1 is lexicographically smaller than that of tree2 and so on. You have to write a perfectly working production code for the above. [Amazon] Q) Find the length of longest path in a binary tree. A path is any path from any node to any other node. Now extend this for an n-ary tree. As for every amazon question, you have to write perfectly working code. [Amazon] Q) Implement lock using semaphores. [Amazon] Q) a) You are given a large dictionary. It contains n words each of length l. You have to find all the words,whose palindrome also occurs in the dictionary. The dictionary is not sorted. You have to do this in O(n*l). b) I gave some answer using trie. Now the next question I was asked was, given the above dictionary, you have to find the number of nodes that will be required for construction of the trie, without actually constructing the trie. In this case you are allowed to sort the dictionary. [Amazon] Q) Given a Stick of any length L. It is broken in three parts.What is probability that these parts will make a Triangle. [Microsoft] Q) Write working code for Serializing and Non-Serializing a non-complete n-ary tree.Nodes of tree contain String of variable length as data. Also, code should work on all test cases possible. [Microsoft] Q) Write a program to find the kth largest element in a heap, without changing the heap itself. [Amazon] Q) Wrote code to find the largest element in an array. [GS-Intern] Q) You have 4 people (A, B, C and D) that need to cross a bridge under 13 min and only 1 flashlight. You can only go with the flashlight, no more than 2 persons at a time, and always as fast as the slowest person. To cross the bridge persons need: A=1min; B=2min; C=5min; D=6min. How do you get all 4 of the across in only 13 min? [GS-Intern] Q) Given two polygons. Write a C code to find whether one polygon is inside, outside or intersecting the other polygon. Polygons can be Concave or convex. [Adobe]

Q) Write a program to print tree in Zig-Zag form as follows: 1 2 3 4 5 6 7 Above tree is to be printed as : 1 3 2 4 5 6 7 or 1 2 3 7 6 5 4 [Citrix]

Q) write a Program to find common ancestor of given n nodes in a binary tree. [Microsoft] Q) Write a program to make mirror tree of given binary tree ITERATIVELY. [Microsoft] Q) Write code for binary search. [Adobe] Q) a)Explain heap-sort with an example. b)Last node of heap1 is removed and heap2 is attached at the end, now how will u make it a heap. (He was just expecting to explain the heapification) [Adobe] Q) What are pure virtual functions? What is use of Abstract classes.(He needed answer related to Object Slicing) [Adobe+Microsoft] Q) Write a function to return 1st 10 elements of fibonacci series in a linked list. [Adobe] Q) How will u define a structure for a helicopter. [Adobe] Q) What are the different ways of storing a graph. [Adobe] Q) A curve is drawn on a paper and given a direction of viewing, u have to find out the visible portions of the curve. [Adobe] Q) Some ques on OS like why multi-threading?

difference between process and thread? what happens when u double-click an application at OS level? [Adobe] Q) Ques related to Virtual mechanism in c++. [Adobe] Q) Tell the function of Session and Presentation layer in OSI model [Cisco] Q) How IPC is done , and what are various methods of IPC (inter process communication)? [NetApp] Q) Does C support nested functions? Give answer with reasons. [NetApp] Q) How will you make a driver for implementing a particular function in your PC. Give general steps. [NetApp]

Q) Suggest an algorithm to find all pythagorian triplets in an array of numbers. [Microsoft] Q) Given a large string and 2 smaller strings(words).ill have to find out the min distance between the 2 smaller words in the large string. for ex large string is "i am a very good and i am a very nice person" and the 2 small words "am" and "and".here "am" occurs as 2nd and eighth word and "and" occurs as 6th word.the minimum distance will be 2(8-6). [Microsoft] Q) Difference between 32bit and 64 bit operating system. [Cisco] Q)Question on ICMP protocol. [Cisco] Q)Reversal of a linked list using single pointer. [Cisco] Q)Write a code to find an element (in an array of size N) which is repeated more than N/2 times. [Cisco]

Q)How user interact with operating system(detailed description). [Cisco] Q)Vertical order traversal of a binary tree. [Amazon] Q)Binary search on k rotated array. [Amazon] Q)There are 25 horses and only five tracks in a race (i.e., you can race 5 horses at a time). What is the minimum number of races needed to determine the 4 fastest horses.(slide change from famous puzzle in which we have to find top 3). [Amazon] Q)cat file | grep pattern, a detailed description about this command was asked, how many process will be created and how the whole process will take place. [Novell] Q) Sheduling algorithm used by the Linux System,detailed description of process sheduling and assignment of priority to processes in Linux. [Cisco] Q)Memory management policy used by Linux System. [Cisco] Q)Find all the substrings which are repeated in a given string. [Adobe] Q) What is constructor initializer list and why do we need it?(he wanted answer related to const data member and references as a data member) [Yahoo] Q)You have to ship an item from one place to another place and cost of transpotation between every two places is given .You have to minimize the cost of transpotation.Suggest a method to implement it. [Yahoo] Q)What is thread safe programming? what problems can occur with using threads in programming [Yahoo] Q)What is a kernel? [Yahoo] Q)What is the difference b/w Java and C++?what is garbage collector?what is Jvm?what is memory leakage? [Yahoo] Q)What is the logic behind detection of loop in a linked list.(Why do we increase one pointer by one link and other by two link?) [Yahoo] Q)Find maximum rectangular submatrix containing all 1s from a rectangular boolean matrix. [Yahoo] Q)Reverse a linked list using one extra pointer(iterative). [Yahoo] Q)Design a Tic Tac Toe game . [GoldmanSachs] Q)What are the test cases for using remote. [GoldmanSachs]

Q)Sort the large no. of integers but you cant load all at a time as you have a less RAM(I used bit vector) [Goldman Sachs] Q)Can we kill one thread from another thread . How is it done in Java? [Goldman Sachs] Q)How to generate a next pandigital no? [Goldman Sachs] Q)Write sql to Find the details of employee who are having their salary greater than their bosss salary.(Use self inner join) [ThoughtWorks] Q)You have an image which is cut into several parts of arbitrary shapes and arranged randomly. You have to construct the original image. Suggest an alogrithm for that.(You dont have the original image.) [Adobe] Q)How to know whether two figures are intersecting or not [Adobe] Q)You have to design a data structure and functions to store an image which can have any shape and anyone can do query to find different shapes from that figure.Suppose you want to find the image which is half circle at bottom and triangle at top from a given figure.(In short implementation of pattern recognition in image.) [Adobe] Q)Design a common function to sort nos., strings,stack, queue,array in C.(not in C++. i.e. you have to implement template kind of thing.You can define ur header file to use that function) [Adobe] Q) You are given description of many no. of shapes of all kind ( triangle, circle, complex polygons) and a rectangular sheet . How would you cut out as many as shapes out of that rectangle such that the scrap left at the last is minimum ? [Adobe] Q) A display screen is given containing many no. of non-overlapped shapes of all kind. A user click on the screen. Now the shape in which user clicks should get highlighted. If it click out of all shapes nothing should happens. Tell your approaches. [Adobe] Q) Given a string , you have to return all the different words as separate string ie you have to tokenize that string. ( The original string should not get destroyed ). [Adobe] Q) a) Questions about scheduling of user level threads and kernel level threads ? b) Make a deterministic finite state machine diagram of a regular expression ? c) Write code for reverse of singly linked list d) Write code for shuffle merging of two linked list ( you have to make a new linked list , do not modify the given two LL ) e) A vehicle class is given and its derived class as car,truck etc. At any time you have to calculate the total no. of vehicle and no. of vehicle of each kind. How would you do that. [Adobe]

Q) Given a matrix of 1s and 0s.This matrix represents a maze in which 1 means blocked path and 0 means open path.You are given a source and destination.Write a program for printing a) only one path fron source to destination. b)all paths fron source to destination. [Microsoft]

Q)Discussion about memory allocated on heap and stack. [Microsoft]

Q) Given an integer n representing number of bits.You can make 2^n unsigned numbers using n bits.Write a program to count how many numbers are there which have no two ones adjacent in their binary representation. [Microsoft]

Q) Write a program to make a singly link list from tree so that last node of previous level should point to first node of next level.No extra memory is allowed. e.g. 1 2 3 4 5 6 7 link list will be like this : 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 ->NULL [Microsoft]

Q) One question of designing.Detail discussion about how can we improve its performance. [Microsoft]

Q) Algorithm of counting sort with example and some discussion about memory needed in counting sort. [Microsoft]

Q) You are given a link list.Write a working for finding nth node from last in this link list. [Microsoft]

Q) You are given an unsigned number .Write a program to find out this number is palindrome in its bit representation or not. [Citrix] Q) You have to define a MACRO which has the following prototype. F(A,B,C,D) After using this macro as F(name, float, a,b) , I should be able to use the variables name.a and name.b. Also, make sure that your implementation is reusable, ie I can use F more than once in the same block. Also extend it so that a predefined prefix is added to the variable. ie. if prefefined prefix is pt, then after using this macro, I should be able to use pt_name.a, and pt_name.b. [Citrix] Q) Detail discussion about circuit switching and packet switching. [Citrix] Q) One program of fork and discussion about different situations in this program. It was related to the address space of the parent and child processes. [Citrix] Q) You have a number written starting from 1 to infinitive. You are performing some iteration. In 1st iteration you are removing number at a gap of one , in second iteration you are removing number at a gap of two in remaining list and so on.You are given a number you have to tell that it will be remove after certain iteration or not.Also calculate the complexity of you algorithm and improve it if you can. [Citrix]

Q) One Question of designing . You have a hotel .In this hotel some rooms are free some are occupied. a) Design a data structure for it. b) What will you do to allocate random room number. c) Improve deficiency in b. [Citrix]

Q) m arrays of n size, new array such that diff betn min and max is min.. Q) kth largest element in a heap. Q) Implement Random(a,b) using Random(0,1). Q) Given n rectangles, find if any two rectangles are intersecting.. Q) Given a BST, find the kth largest element. Q) Insertion and Search in Youngs tableau. Q) Vertical order traversal of an n-ary tree. Q) Run Length encoding... Q) Print a tree as a tree. Q) Given a pattern P(containing unique characters) and a string S find the minimum window in S which contains all the characters in P. Q) Given a graph in which all the edges are of unit length, device an algorithm which can find shortest path from source node to destination node in minimum complexity. Q) There exists a ticket collector with initial amount 0 Rs. n persons have 10 rs and m persons have 5rs. The cost of ticket is 5 Rs. If these people stand in a line, how many permutations exist such that the ticket collector will always be able to provide change for the ticket. Q) Given a disconnected graph, find the no of disconnected components. Q) Liar Liar puzzle. Q) Analysis of quicksort. Q) Increment a binary no. in a string. Find the complexity of this algorithm. Q) How many bits required to convert one integer to another.. Q) Given an array of integers, find the contiguous sub-array with the largest [Microsoft] [Microsoft]

sum.

VMWare Questions

1. How will u implement c++ features ( inheritance and access control) in c. 2. If i want to make windows exe also work on linux wat modifications need to be done on kernel 3. ques abt VFS and NFS 4. wat is meant by device driver. wat will happen if ur comp doesnt hav driver 5. how serial data is converted to parallel. which 1 is better 6. is it possible to hav software raid. how will u implement 7.wats the datastruct used in text prediction while typing ( trie) 8.wats persistence timer 9. control flow in tcp 10. wat will happen if u use switch in place of 3 layer router

You might also like