Sei sulla pagina 1di 16

Sheet1

DS and Alogs

Page 1

Sheet1

c/c++/java

Page 2

Sheet1

os

miss

Page 3

Sheet1
Design patterns

Page 4

Sheet1

Segregate balls of red, blue and black color stored in an array


Given 2 sorted arrays , find kth smallest element among them
Reverse a linked list in place, without returning the head pointer
Search-in-row-wise-and-column-wise-sorted-matrix
Reverse-level-order-traversal
A-linked-list-with-next-and-arbit-pointer
Method to determine whether a number is a power of two
Find number of set bits in a number
Find largest and second largest number in an array with minimum number of comparisons
What is inorder, preorder, postorder. write the code and the output for the given binary tree
What data structure is used for dictionary. What are limitations of that data structure
Given a binary search tree to be transmitted over a network, WAP to store the BST at sender side and recreate BST on recei
WAP to read through a file and print tokens of length 5 comprising of alphanumeric characters only.
how to make a tree from the combination of any two, also write the full function code. why cant we make binary tree from post
Find the intersection point of two linked lists with full code
You are given 4 (x,y) coordinates of a rectangle, 1 (x,y) coordinate of a circle and its radius. write the code to find if the rectang
A sorted array is rotated around an element. Modify binary search to search for an element in the array.
Implement n-ary tree using down-right approach,Traversal both level-order and in-order
tell whether a string of parenthesis is valid or not
What data structure would you use to store a composite linked list?
Implement malloc and free
Design and implement garbage collector in C.
Many aspects were discussed here.
When to trigger?
Who is responsible?
Which memory to free?
Given an integer number, how would you determine if it is a palindrome
Given a integer number, find the next higher palindrome number
Code to check if a binary tree follows the below property.
Every nodes data = sum of left subtree + sum of right subtree
Given an infinite stream of boolean digits, need to tell at runtime whether the number received so far is a multiple of 3
Code for given a sorted but pivoted array, find the ceiling of a given number
Big endian and little endian architecture.
How to identify if big endian or little endian
Given a fairly large number, need to tell whether the number is part of fibonacci series or not
you have an the heights of the bars given in an array first you have to tell the amount of rain water trapped between the bars
print all the permutations of a string with and without repeating characters
implement and tell the complexity of inserting a value in a vector in c++
spell checker
Write code to make mirror of a binary tree in-place.
Questions on static variables, malloc, calloc, pointers and how they work
MyNameIsRam , you need to convert this to my name is ram
an array to balanced binary search tree
duplicates in a string
Implement quick sort
Given two binary trees A and B. Check if B is a subtree of A.

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

Compare C and C++/Java


polymorphism
method overloading
method overriding
Constructor
handling errors, dangling pointer, memory leak
Suppose a class takes positive Integers only, what will happen if we try to create an object giving negative value. How to catch
how to compile two .cpp codes together.
what is makefile? Utilities
where is printf stored? all the internal details.
what does stdio.h do? difference between #include and #include <>
Page 6

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

nder side and recreate BST on receiver side

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.

eived so far is a multiple of 3

(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

ction or just the prototype?

pending a lot of money. how will you do it?

Page 11

Sheet1

Page 12

Sheet1

mum water trapped

Page 13

Sheet1

Page 14

Sheet1

Page 15

Sheet1

Page 16