Professional Documents
Culture Documents
DS and Alogs
Page 1
Sheet1
c/c++/java
Page 2
Sheet1
os
miss
Page 3
Sheet1
Design patterns
Page 4
Sheet1
Page 5
Sheet1
Given an array of numbers all of which are repeated only one non repeated, find the non repeated number.
Gave the algorithm using XOR.
Find the kth smallest element in an unsorted array of number
-http://www.geeksforgeeks.org/check-if-a-given-binary-tree-is-sumtree
find the element before which all the elements are smaller than it, and after which all are greater then it.
An array is given of size m. First n elements (n < m) are filled and rest contains junk. Write code for linear
search to find an element x in first n elements. There would be 2 comparisons per iteration: (i < n) in for loop
and (arr[i]==x). You have to reduce the no. of comparisons to 1 comparison/iteration.
There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration
(comparision). All the nuts/bolts might have different diamete
There is a paragraph having million characters. You have to find out the first non repeating character in the
complete paragraph. For example:- aab cld jb then answer should be :- c
Any base to any base conversion i.e base 11 to base 7
Questions related to Multi-Threading i.e synchronization or usage of Volatile (Basic questions)
Garbage collection algorithms
There are chocolates each worth x. You have total amount y with you. And you can exchange z wrappers for 1
chocolate. So in this way how many chocolates he can eat.
Declare a 2D array using pointer notation.
Suppose there are packages having volume m and there are n packets having volume a,b,c. each having
volume less than m. So you need to find out the minimum no. of packets required to wrap up the products.
There are N cities spread in the form of circle. There is road connectivity b/w city 1 and 2, then city 2 and 3 and
so on till city n and 1. Each ith city has a petrol pump where you can pick pith petrol and distance between ith
and i+1 th city is di . Assume you car has a mileage of 1km/litre. You have to find out if there exist any city, if
you start from that city then you can visit all the cities either in the clockwise or anticlockwise fashion.
Reverse a string. Reverse a paragraph word-wise.
Write a function to connect all the adjacent nodes at the same level in a binary tree. Structure of the given Binary
Implement a push pop operations in a stack. Implement a queue using stacks. Remember there is further
optimization, he asked me for that.
Write complete code for the number of ways a frog can reach nth step by jumping 1 or 2 steps.
Replace a string with another string in a paragraph. Which data structure you will use. Complete code.
Implement a generic swap function. I wrote a function which swap the pointers but he wanted me to swap the
complete memory blocks not just the pointers
Spiral order traversal of a matrix. Complete code and he ran it for a 44 matrix
Calculate Fibonacci for nth term. He was asking to optimize the traditional solution
Write a function which returns 1 when 2 is passed and return 2 when 1 is passed
1 number is missing from an array(1 to n). find that
Sheet1
what gets included when we do #include?? does it includes the whole definition of the function or just the prototype?
what is the role of assembler in gcc a.c
what does linker do? hwo does it link? functions of a loader?
Explain all the compilation steps in this command gcc a.c b.c c.c
Memory layout of a C program
He asked me to write code for hello world in C. Then he asked where this printf is stored and how compiler
knows where to check that thing. If printf declaration is moved to the program will it get executed. I told him
that I am not aware of these things.
What is thread?
What problems arise with multithreaded applications?
How are they solved?
Difference between semaphore and mutex?
explain logical and physical memory
explain paging
between process and a thread etc
Tell me about fragmentation. Internal and External both. How it happens
Asked about Paging
How space is allocated to processes in memory.
What is defragmentation? How it works?
What happens when I execute a process like play a video in my PC
Design a mobile app which tells nearest restaurants to your current location. Discussion on how restaurants
should be stored on database. How should database be searched for restaurants based on current location. How it
can be optimized in case of remote areas and dense population areas
Consider a directory Structure. Given a file object of outermost directory, print unique names of files. You are
given a predefined isFolder() method
Consider an alarm system with operations:
addEvent(eventId,time,callback()) Callback function could be playing a ringtone on the alarm.
removeEvent(eventId)
updateEvent(eventId,time)
executeEvent(time) This will call the callback function of the event to be executed at the given time.
Discussion on possible data structure to be used along with complexities of each so that executeEvent function is
optimized i.e. takes least time
There is a lake, it can have any random shape, you have to measure its volume without spending a lot of money. how will you
Design a model for implementing sync mechanism for Google drive.
(handling only the client side).
Same file can be accessed and modified by different clients.
Take care of power failure, no internet connection scenarios too
Given a rectangular sheet of paper, and a set of very irregular shapes.
I was to cut these shapes out of the paper, in such a way
that there is a good mix of all the pieces and the wastage of paper is minimal.
When I say irregular, it can also have a hole in the middle
what happens when you type a URL in your web browser
he asked me to design a web browser and cover every aspect of it
Design a transaction system for a bank with many atms across. He asked me if you want to deal with the bank
how will you explain them the model and all the software and hardware requirements. He wanted a
multithreaded client- server interaction model and the database requirements
Page 7
Sheet1
Asked to explain the MVC design Pattern.
Page 8
Sheet1
y cant we make binary tree from post and preorder? Explained well
s. write the code to find if the rectangle and the circle intersect?
nt in the array.
(5*n2 + 4) or (5*n2 4)
ain water trapped between the bars and then he extended the question to finding the block with maximum water trapped
Page 9
Sheet1
t giving negative value. How to catch the error. How is the memory deallocated for the object
Page 10
Sheet1
Page 11
Sheet1
Page 12
Sheet1
Page 13
Sheet1
Page 14
Sheet1
Page 15
Sheet1
Page 16