top of page
  • Facebook
  • Twitter
  • Instagram

Top Data-Structures Interview Questions

Mobiprep handbooks are free downloadable placement preparation resources that can help you ace any company placement process. We have curated a list of the 40 most important MCQ questions which are asked in most companies such as Infosys, TCS, Wipro, Accenture, etc. The placement handbooks also have detailed explanations for every question ensuring you revise all the questions with detailed answers and explanations.

Question

25

Explanation

What are the operations can be performed on stacks and queues?

Stacks

push() − adds an item to stack
pop() − removes the top stack item
peek() − gives value of top item without removing it
isempty() − checks if stack is empty
isfull() − checks if stack is full

Queues

enqueue() − add (store) an item to the queue.
dequeue() − remove (access) an item from the queue.
peek() − Gets the element at the front of the queue without removing it.
isfull() − Checks if the queue is full.
isempty() − Checks if the queue is empty.

Question

26

Explanation

How will you detect a loop in a linkedlist?


Use two pointer method.
Traverse the linkedlist using two pointers. Move one pointer by one and another pointer by two. If the pointers meet at same node then there is a loop.

Question

27

Explanation

Write the algorithm for level order traversal of a binary tree.

printLevelorder(tree)
1) Create an empty queue q
2) temp_node = root
3) Loop while temp_node is not NULL
a) print temp_node->data.
b) Enqueue temp_node’s children (first left then right children) to q
c) Dequeue a node from q and assign it’s value to temp_node

Question

28

Explanation

What is the minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers?


> The First occurence of an element can be found out in O(log(n)) time using divide and conquer technique,lets say it is i.
> The Last occurrence of an element can be found out in O(log(n)) time using divide and conquer technique,lets say it is j.
> Now number of occuerence of that element(count) is (j-i+1). Overall time complexity = log n +log n +1 = O(logn).

bottom of page