Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

MSC PLACEMENTS 2K12 (Data Structures Aptitude)

1. Given an array and a number k where k is smaller than size of array, we need to find the kth
smallest element in the given array. It is given that all array elements are distinct.
2. Given three arrays sorted in non-decreasing order, print all common elements in these arrays.
3. Given an array of 0s and 1s, find the position of 0 to be replaced with 1 to get longest continuous
sequence of 1s. Expected time complexity is O(n) and auxiliary space is O(1).
4. Given two sorted arrays and a number x, find the pair whose sum is closest to x and the pair has
an element from each array.
5. Given a sorted array (sorted in non-decreasing order) of positive numbers, find the smallest positive
integer value that cannot be represented as sum of elements of any subset of given set.
Expected time complexity is O(n).

6. Given a linked list of co-ordinates where adjacent points either form a vertical line or a horizontal line.
Delete points from the linked list which are in the middle of a horizontal or vertical line.

7. You are provided with linked list, you have to delete nodes, But in the delete operation you are not
allowed to access head pointer or create reference to head or create new head pointer .Now user want to
delete node which is head, How will you handle this? [Hint: Think Different]

8. Given a linked list, reverse alternate nodes and append them to end of list. Extra allowed space is O(1)
9. Given a singly linked list, swap kth node from beginning with kth node from end. Swapping of data is not
allowed, only pointers should be changed.

10. Remove loop from a linked list . You are provided with the head pointer of linked list with loop.
11. Given a linked list where in addition to the next pointer, each node has a child pointer, which may or may
not point to a separate list. These child lists may have one or more children of their own, and so on, to
produce a multilevel data structure, as shown in below figure.You are given the head of the first level of
the list. Flatten the list so that all the nodes appear in a single-level linked list
You need to flatten the list in way that all nodes at first level should come first, then nodes of second level,
and so on.

Each node is a C struct with the following definition.


struct list
{
int data;
struct list *next;
struct list *child;
};
12. You are given a Queue data structure that supports standard operations like enqueue() and dequeue().
Imlement a stack using queue;
13. You have to find the nth node from end of link list by passing the list only once
14. You have to find middle node of linked list in just one pass.
15. You are given an array of n elements having values from 1..N . In which only one is duplicated . Find the
duplicate by scanning the array only once.

You might also like