Basic Data Structures # MCQs Practice set

Q.1 Which of the following data structures uses FIFO (First In First Out) principle?

Stack
Queue
Tree
Graph
Explanation - Queue follows FIFO, meaning the first element added is the first to be removed, unlike a stack which follows LIFO.
Correct answer is: Queue

Q.2 In a stack, which operation removes the top element?

Push
Pop
Enqueue
Dequeue
Explanation - Pop operation removes the top element of a stack, while Push adds an element.
Correct answer is: Pop

Q.3 Which data structure is best suited for implementing a priority queue?

Array
Linked List
Heap
Stack
Explanation - Heap allows efficient insertion and extraction of elements based on priority, making it ideal for a priority queue.
Correct answer is: Heap

Q.4 Which of the following is not a linear data structure?

Array
Linked List
Stack
Binary Tree
Explanation - Binary Tree is a hierarchical (non-linear) data structure where elements are arranged in a tree-like structure.
Correct answer is: Binary Tree

Q.5 What is the time complexity of accessing an element by index in an array?

O(1)
O(n)
O(log n)
O(n log n)
Explanation - Array elements are stored in contiguous memory, so accessing any element by index takes constant time.
Correct answer is: O(1)

Q.6 Which data structure uses LIFO (Last In First Out) principle?

Queue
Stack
Tree
Graph
Explanation - Stack follows LIFO, meaning the last element added is the first to be removed.
Correct answer is: Stack

Q.7 Which data structure is used for recursion?

Queue
Stack
Array
Graph
Explanation - Function calls in recursion are managed using a call stack, following LIFO principle.
Correct answer is: Stack

Q.8 Which of the following is a self-referential data structure?

Array
Linked List
Queue
Stack
Explanation - Linked List nodes contain a pointer to the next node, making it self-referential.
Correct answer is: Linked List

Q.9 What is the worst-case time complexity of searching an element in a singly linked list?

O(1)
O(n)
O(log n)
O(n^2)
Explanation - In a singly linked list, elements must be accessed sequentially, leading to O(n) worst-case search time.
Correct answer is: O(n)

Q.10 Which data structure is used to implement function call management in programming languages?

Queue
Stack
Array
Graph
Explanation - Stack stores information about active subroutines/functions in programming languages, enabling recursion.
Correct answer is: Stack

Q.11 Which of the following is a non-linear data structure?

Queue
Stack
Graph
Array
Explanation - Graph organizes elements in nodes and edges, forming a network, unlike linear structures.
Correct answer is: Graph

Q.12 Which operation adds an element at the rear of a queue?

Enqueue
Dequeue
Push
Pop
Explanation - Enqueue operation inserts an element at the rear of the queue, while Dequeue removes from the front.
Correct answer is: Enqueue

Q.13 In a doubly linked list, each node contains how many pointers?

One
Two
Three
Four
Explanation - Each node has a pointer to the previous and next node, making two pointers per node.
Correct answer is: Two

Q.14 Which data structure allows insertion and deletion from both ends?

Stack
Queue
Deque
Array
Explanation - Deque (Double-Ended Queue) allows insertion and deletion from both front and rear ends.
Correct answer is: Deque

Q.15 Which of the following is a static data structure?

Array
Linked List
Stack (dynamic)
Queue (dynamic)
Explanation - Array size is fixed at compile time (static), while linked lists and dynamic stacks/queues can grow at runtime.
Correct answer is: Array

Q.16 Which data structure is suitable for undo functionality in text editors?

Queue
Stack
Array
Graph
Explanation - Stack can reverse operations, following LIFO principle, making it ideal for undo operations.
Correct answer is: Stack

Q.17 Which of the following operations is not allowed in a stack?

Push
Pop
Peek
Insert at bottom
Explanation - Stack allows only push (top insert), pop (top remove), and peek operations; bottom insertion violates LIFO.
Correct answer is: Insert at bottom

Q.18 What is the time complexity of inserting an element at the end of a singly linked list if tail pointer is maintained?

O(1)
O(n)
O(log n)
O(n log n)
Explanation - With a tail pointer, insertion at the end can be done directly without traversing, taking constant time.
Correct answer is: O(1)

Q.19 Which of the following is true about circular queue?

Front always points to first element
Rear always points to last element
Positions are reused after deletion
Queue size keeps increasing
Explanation - Circular queue reuses empty positions after deletion, efficiently utilizing storage.
Correct answer is: Positions are reused after deletion

Q.20 Which data structure is commonly used in breadth-first search (BFS) of a graph?

Stack
Queue
Heap
Linked List
Explanation - BFS uses a queue to explore nodes level by level.
Correct answer is: Queue

Q.21 Which of the following is an advantage of linked list over arrays?

Random access of elements
Efficient memory utilization
Constant time search
Easier to sort
Explanation - Linked lists allocate memory dynamically, reducing wasted space compared to static arrays.
Correct answer is: Efficient memory utilization

Q.22 Which of the following is used to implement recursion in programming languages?

Queue
Stack
Heap
Array
Explanation - Recursion uses the call stack to track active function calls.
Correct answer is: Stack

Q.23 Which of the following is a disadvantage of arrays?

Fixed size
Sequential memory allocation
Random access
Supports iteration
Explanation - Arrays have a fixed size, so resizing requires creating a new array and copying elements.
Correct answer is: Fixed size

Q.24 Which data structure is suitable for implementing a call stack in programming?

Queue
Stack
Deque
Array
Explanation - Stack naturally supports LIFO order, which is needed for managing function calls.
Correct answer is: Stack