Introduction to Data Structures # MCQs Practice set

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

Tree
Graph
Array
Binary Search Tree
Explanation - Arrays store elements sequentially, making them linear. Trees and graphs are non-linear structures.
Correct answer is: Array

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

O(1)
O(n)
O(log n)
O(n log n)
Explanation - Arrays allow direct access via index, so retrieval is constant time.
Correct answer is: O(1)

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

Queue
Stack
Linked List
Graph
Explanation - Stacks follow Last In First Out order, where the last element inserted is removed first.
Correct answer is: Stack

Q.4 Which data structure uses FIFO (First In First Out) principle?

Stack
Queue
Tree
Heap
Explanation - Queues follow First In First Out order, where the first element inserted is removed first.
Correct answer is: Queue

Q.5 What is the main advantage of a linked list over an array?

Faster access by index
Dynamic size
Easier sorting
Less memory usage
Explanation - Linked lists can grow and shrink dynamically, unlike arrays which have fixed size.
Correct answer is: Dynamic size

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

Queue
Stack
Linked List
Binary Tree
Explanation - Binary trees are hierarchical and non-linear, unlike stacks and queues which are linear.
Correct answer is: Binary Tree

Q.7 In a singly linked list, which operation is more efficient compared to arrays?

Accessing an element by index
Inserting an element in the middle
Sorting
Searching
Explanation - Insertion in a linked list only requires updating pointers, unlike arrays where elements must be shifted.
Correct answer is: Inserting an element in the middle

Q.8 What is a key characteristic of a doubly linked list?

Each node points to the next node only
Nodes contain multiple data elements
Each node points to both previous and next nodes
It uses arrays internally
Explanation - Doubly linked lists allow traversal in both directions using prev and next pointers.
Correct answer is: Each node points to both previous and next nodes

Q.9 Which data structure is suitable for implementing a priority queue?

Array
Heap
Stack
Queue
Explanation - Heaps allow efficient retrieval of the highest (or lowest) priority element, ideal for priority queues.
Correct answer is: Heap

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

O(1)
O(n)
O(log n)
O(n log n)
Explanation - In a linked list, you may need to traverse all nodes to find an element.
Correct answer is: O(n)

Q.11 Which data structure is used for recursive function calls?

Queue
Stack
Array
Graph
Explanation - Function calls are pushed onto the call stack and popped after execution, following LIFO.
Correct answer is: Stack

Q.12 Which data structure is optimal for implementing undo operations in software?

Queue
Stack
Linked List
Heap
Explanation - Undo operations follow LIFO order; the last action performed is the first to be undone.
Correct answer is: Stack

Q.13 In an array of size n, what is the time complexity of inserting an element at the end?

O(1)
O(n)
O(log n)
O(n log n)
Explanation - If there is space available, inserting at the end of an array is a constant time operation.
Correct answer is: O(1)

Q.14 Which of the following is not a type of linked list?

Singly linked list
Doubly linked list
Circular linked list
Dynamic array list
Explanation - Dynamic array is an array with resizable size, not a linked list type.
Correct answer is: Dynamic array list

Q.15 Which data structure is best suited for implementing BFS (Breadth First Search)?

Stack
Queue
Linked List
Heap
Explanation - BFS explores nodes level by level and uses a queue to keep track of the next node to visit.
Correct answer is: Queue

Q.16 What is the primary disadvantage of arrays over linked lists?

Random access
Fixed size
Easy traversal
Better memory usage
Explanation - Arrays have a fixed size, so dynamic insertion or deletion is costly or impossible without resizing.
Correct answer is: Fixed size

Q.17 Which of the following is a dynamic data structure?

Array
Stack
Linked List
String
Explanation - Linked lists allocate memory as needed, unlike arrays which are static in size.
Correct answer is: Linked List

Q.18 In a circular linked list, the last node points to:

NULL
The first node
Its own node
Random node
Explanation - Circular linked lists connect the last node back to the first node for circular traversal.
Correct answer is: The first node

Q.19 Which data structure is ideal for depth-first search (DFS)?

Queue
Stack
Heap
Array
Explanation - DFS uses a stack (or recursion) to explore nodes deeply before backtracking.
Correct answer is: Stack

Q.20 Which of the following structures is not sequential in memory?

Array
Singly linked list
String
Queue implemented using array
Explanation - Linked list nodes can be scattered in memory, unlike arrays which are contiguous.
Correct answer is: Singly linked list

Q.21 Which operation is costly in arrays compared to linked lists?

Accessing by index
Traversing
Insertion/deletion in the middle
Finding length
Explanation - Arrays require shifting elements when inserting or deleting, while linked lists just update pointers.
Correct answer is: Insertion/deletion in the middle

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

Array
Linked List
Queue
Stack
Explanation - Each node in a linked list contains a pointer to the next node, making it self-referential.
Correct answer is: Linked List

Q.23 Which of these is not a primitive data structure?

Integer
Float
Array
Character
Explanation - Primitive data structures include simple types like int, float, char. Arrays are composite structures.
Correct answer is: Array

Q.24 Which of the following is used for memory-efficient insertion and deletion?

Array
Linked List
String
Queue
Explanation - Linked lists allow easy insertion and deletion without shifting elements.
Correct answer is: Linked List

Q.25 Which of the following can be implemented using arrays and linked lists?

Stack
Queue
Both
Neither
Explanation - Both stacks and queues can be implemented using arrays or linked lists depending on requirements.
Correct answer is: Both