Suggestive MCQ questions
Module 1:
Arrays: 1D, 2D and Multi-Dimensional Arrays, Sparse Matrices, Polynomial
representation, Implementation of Stack and Queue, Example of Infix, Postfix, and prefix,
Priority Queue
Easy Level:
1. Which of the following is a correct representation of a 1D array?
a) A[1][1]
b) A[]
c) A[5]
d) A[2][3]
Answer: c) A[5]
2. In a 2D array A[3][4], how many elements are there in total?
a) 7
b) 12
c) 9
d) 6
Answer: b) 12
3. Which of the following is an example of an infix expression?
a) A B +
b) A + B
c) + A B
d) A B *
Answer: b) A + B
4. Which data structure is used to implement recursion internally?
a) Queue
b) Linked List
c) Stack
d) Tree
Answer: c) Stack
5. What is the time complexity to access an element in a 1D array?
a) O(n)
b) O(1)
c) O(log n)
d) O(n^2)
Answer: b) O(1)
Moderate Level:
6. How is a sparse matrix different from a regular matrix?
a) It has more zero elements than non-zero elements
b) It has equal numbers of zero and non-zero elements
c) It has only non-zero elements
d) It has no zero elements
Answer: a) It has more zero elements than non-zero elements
7. Which operation is performed first in the postfix expression AB+C*D?
a) A + B
b) C * D
c) B + C
d) A * C
Answer: a) A + B
8. What is the main advantage of using a priority queue?
a) Items are served in the order they arrive
b) Items are served based on their priority
c) It allows constant time search
d) It reduces the memory usage
Answer: b) Items are served based on their priority
9. Which of the following is true about a stack?
a) Follows FIFO
b) Follows LIFO
c) Can be implemented using trees
d) Always uses a linked list
Answer: b) Follows LIFO
10. In the implementation of a queue using arrays, what happens when the rear pointer
reaches the last element?
a) The queue is full
b) The queue becomes circular
c) The queue resets to the front
d) Rear pointer stops moving
Answer: a) The queue is full
Hard Level:
11. In a multi-dimensional array, which of the following best represents the memory
layout in C/C++?
a) Row-major order
b) Column-major order
c) Alternating row and column
d) Random order
Answer: a) Row-major order
12. Which of the following can NOT be used to implement a priority queue?
a) Heap
b) Binary Search Tree
c) Circular Queue
d) Linked List
Answer: c) Circular Queue
13. What is the postfix notation for the expression (A + B) * (C - D)?
a) AB + CD -*
b) AB + CD - *
c) A B + * C D -
d) A + B * C - D
Answer: b) AB + CD - *
14. In polynomial representation using arrays, how can the degree of a polynomial be
found efficiently?
a) By checking the last non-zero element in the array
b) By checking the first non-zero element in the array
c) By summing all elements
d) By multiplying all elements
Answer: a) By checking the last non-zero element in the array
15. In a sparse matrix representation using a linked list, what does each node typically
store?
a) Only the value of the element
b) Row and column indices along with the value
c) Only the row index
d) The next node’s value
Answer: b) Row and column indices along with the value
Module 2:
Linked Lists: Singly, Doubly and Circular Lists, Normal and Circular representation of
Self Organizing Lists, Skip Lists, and Polynomial representation.
Easy Level:
1. Which of the following best describes a singly linked list?
a) Nodes can only be traversed in one direction
b) Nodes can be traversed in both directions
c) Each node has a pointer to two other nodes
d) It is a linear array structure
Answer: a) Nodes can only be traversed in one direction
2. In a doubly linked list, each node contains:
a) One pointer
b) Two pointers
c) Three pointers
d) Four pointers
Answer: b) Two pointers
3. What is the main advantage of using a circular linked list?
a) It uses less memory
b) It allows for efficient memory allocation
c) It can easily traverse the list from any point
d) It is easier to implement
Answer: c) It can easily traverse the list from any point
4. Which of the following is true about a skip list?
a) It has a constant time complexity for search operations
b) It is a type of balanced tree
c) It is an unordered list
d) It uses pointers to skip elements during traversal
Answer: d) It uses pointers to skip elements during traversal
5. In a polynomial representation using a linked list, each node typically stores:
a) Only the coefficient
b) Only the exponent
c) Coefficient and exponent
d) Only the degree of the polynomial
Answer: c) Coefficient and exponent
Moderate Level:
6. What is the primary use of self-organizing lists?
a) To store data in a sorted manner
b) To reduce access time for frequently accessed elements
c) To eliminate duplicates
d) To maintain a fixed size
Answer: b) To reduce access time for frequently accessed elements
7. In a circular doubly linked list, the last node's next pointer points to:
a) NULL
b) The first node
c) The previous node
d) It has no next pointer
Answer: b) The first node
8. Which of the following is NOT a characteristic of a skip list?
a) Multiple levels
b) Sorted order
c) Uses hash functions
d) Node pointers skip over elements
Answer: c) Uses hash functions
9. What is the time complexity for inserting an element at the beginning of a singly
linked list?
a) O(n)
b) O(1)
c) O(log n)
d) O(n log n)
Answer: b) O(1)
10. In a self-organizing list, how is the order of the nodes determined?
a) By the time they were added
b) By the frequency of access
c) By their value
d) By their size
Answer: b) By the frequency of access
Hard Level:
11. What is the main difference between a skip list and a balanced tree?
a) Skip lists use linked nodes; balanced trees use arrays
b) Skip lists can have multiple levels; balanced trees maintain height
c) Skip lists are unordered; balanced trees are ordered
d) Skip lists use hash tables; balanced trees use pointers
Answer: b) Skip lists can have multiple levels; balanced trees maintain height
12. Which operation is more complex in a doubly linked list compared to a singly linked
list?
a) Insertion
b) Deletion
c) Traversal
d) Memory allocation
Answer: b) Deletion
13. In polynomial representation using linked lists, how do you multiply two
polynomials represented as linked lists?
a) Traverse both lists and add the coefficients
b) Multiply the coefficients and add the exponents
c) Create a new list for each term and merge them
d) Use a hash table to store the products
Answer: c) Create a new list for each term and merge them
14. In a circular linked list, which pointer helps to identify the start of the list?
a) The last node's next pointer
b) The first node's previous pointer
c) The last node's previous pointer
d) The head pointer
Answer: d) The head pointer
15. Which of the following operations can be performed efficiently on a self-organizing
list?
a) Insertions only
b) Deletions only
c) Searching for frequently accessed elements
d) Merging with another list
Answer: c) Searching for frequently accessed elements
Module 3:
Recursion: Definition, Internal Stack representation, Factorial function, Fibonacci
Sequence, The tower of Hanoi Problem.
Easy Level:
1. What is recursion?
a) A function that calls itself
b) A loop that repeats a block of code
c) A process of sorting data
d) A method of searching in data
Answer: a) A function that calls itself
2. Which of the following is a base case in recursion?
a) A case that does not end
b) A case that ends the recursion
c) A case that generates new data
d) A case that requires multiple recursive calls
Answer: b) A case that ends the recursion
3. What is the time complexity of the factorial function using recursion for n!?
a) O(1)
b) O(n)
c) O(n^2)
d) O(n!)
Answer: b) O(n)
4. In a recursive function, what is the purpose of the return statement?
a) To exit the function
b) To pass control to the previous call
c) To print output
d) To declare variables
Answer: b) To pass control to the previous call
5. What does the Fibonacci sequence start with?
a) 0, 1
b) 1, 1
c) 1, 2
d) 0, 2
Answer: a) 0, 1
Moderate Level:
6. Which of the following statements is true about the internal stack in recursion?
a) It is used to store local variables only
b) It grows downward
c) It stores return addresses and parameters
d) It can only handle non-recursive functions
Answer: c) It stores return addresses and parameters
7. How many function calls are made to compute factorial(4) recursively?
a) 4
b) 5
c) 6
d) 8
Answer: b) 5
8. What is the time complexity of the naive recursive implementation of the Fibonacci
sequence?
a) O(n)
b) O(n log n)
c) O(2^n)
d) O(n^2)
Answer: c) O(2^n)
9. In the Tower of Hanoi problem, how many moves are required to transfer n disks
from one peg to another?
a) n
b) 2n
c) 2^n - 1
d) n^2
Answer: c) 2^n - 1
10. Which of the following is NOT a characteristic of recursion?
a) Base case
b) Recursive case
c) Infinite loops
d) Stack overflow
Answer: c) Infinite loops
Hard Level:
11. What is the primary drawback of using recursion in programming?
a) It is always faster than iteration
b) It requires more memory due to stack usage
c) It is easier to write
d) It is less readable
Answer: b) It requires more memory due to stack usage
12. In the context of the Tower of Hanoi problem, what is the role of the helper peg?
a) It stores the largest disk
b) It holds disks temporarily
c) It serves as the destination peg
d) It cannot be used
Answer: b) It holds disks temporarily
13. Which of the following is a characteristic of tail recursion?
a) The recursive call is not the last operation in the function
b) It can lead to stack overflow
c) It can be optimized by the compiler
d) It uses more stack space
Answer: c) It can be optimized by the compiler
14. How is the Fibonacci sequence calculated in a recursive function?
a) F(n) = F(n-1) + F(n-2)
b) F(n) = F(n-1) * F(n-2)
c) F(n) = F(n+1) + F(n-1)
d) F(n) = F(n-2) - F(n-1)
Answer: a) F(n) = F(n-1) + F(n-2)
15. What can cause a stack overflow in a recursive function?
a) Base case is not defined
b) Infinite recursion
c) Large input values
d) All of the above
Answer: d) All of the above
Module 4:
Trees: Introduction to Tree as a data structure, Binary Trees (Insertion, Deletion,
Recursive and Iterative Traversals of Binary Search Trees), Threaded Binary Trees,
Height-Balanced Trees (Various operations on AVL Trees).
Easy Level:
1. What is the maximum number of children a node can have in a binary tree?
a) 1
b) 2
c) 3
d) Any number
Answer: b) 2
2. Which traversal method processes the root node before its children in a binary tree?
a) In-order
b) Pre-order
c) Post-order
d) Level-order
Answer: b) Pre-order
3. In a binary search tree (BST), which of the following is true for any given node?
a) All values in the right subtree are less than the node's value
b) All values in the left subtree are greater than the node's value
c) All values in the left subtree are less than the node's value
d) There are no specific rules for subtree values
Answer: c) All values in the left subtree are less than the node's value
4. What is the height of a binary tree?
a) The number of nodes in the tree
b) The number of edges on the longest path from the root to a leaf
c) The number of leaves in the tree
d) The total number of nodes
Answer: b) The number of edges on the longest path from the root to a leaf
5. Which of the following is NOT a type of binary tree?
a) Complete Binary Tree
b) Full Binary Tree
c) Balanced Binary Tree
d) Circular Binary Tree
Answer: d) Circular Binary Tree
Moderate Level:
6. What is the primary benefit of using a threaded binary tree?
a) It allows faster insertion
b) It reduces the height of the tree
c) It facilitates in-order traversal without using a stack or recursion
d) It allows duplicate nodes
Answer: c) It facilitates in-order traversal without using a stack or recursion
7. Which of the following is the time complexity for searching an element in a balanced
binary search tree?
a) O(n)
b) O(log n)
c) O(n log n)
d) O(1)
Answer: b) O(log n)
8. What happens to the height of an AVL tree when a node is inserted that causes it to
become unbalanced?
a) The tree remains the same
b) The height is adjusted by rotations
c) The height is reduced by one
d) The tree is deleted
Answer: b) The height is adjusted by rotations
9. In an iterative in-order traversal of a binary search tree, what data structure is
typically used?
a) Queue
b) Array
c) Stack
d) Linked List
Answer: c) Stack
10. What is the balance factor of a node in an AVL tree?
a) The difference between the number of left and right children
b) The height difference between the left and right subtrees
c) The total number of nodes in the subtree
d) The depth of the node
Answer: b) The height difference between the left and right subtrees
Hard Level:
11. Which rotation is performed in an AVL tree when a node is inserted into the right
subtree of the right child?
a) Left rotation
b) Right rotation
c) Left-Right rotation
d) Right-Left rotation
Answer: b) Right rotation
12. What is the time complexity for deleting a node in a binary search tree in the
average case?
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: b) O(log n)
13. In a binary search tree, which of the following nodes can replace a deleted node with
two children?
a) The left child
b) The right child
c) The inorder predecessor or successor
d) Any child node
Answer: c) The inorder predecessor or successor
14. Which traversal method would you use to get nodes in non-decreasing order in a
binary search tree?
a) Pre-order
b) In-order
c) Post-order
d) Level-order
Answer: b) In-order
15. What is the purpose of a sentinel node in a threaded binary tree?
a) To mark the end of a tree
b) To store data
c) To facilitate traversal
d) To replace null pointers
Answer: d) To replace null pointers
Module 5:
Searching and Sorting: Linear Search, Binary Search, Comparison of Linear and Binary
Search, Selection Sort, Insertion Sort, Merge Sort, Quick sort, Shell Sort, Comparison of
Sorting Techniques.
Easy Level:
1. What is the main advantage of binary search over linear search?
a) Simplicity
b) Lower time complexity
c) Less memory usage
d) Ability to search unsorted arrays
Answer: b) Lower time complexity
2. In which type of search is the data required to be sorted?
a) Linear search
b) Binary search
c) Both linear and binary search
d) Neither linear nor binary search
Answer: b) Binary search
3. What is the time complexity of linear search in the worst case?
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: c) O(n)
4. Which sorting algorithm repeatedly selects the minimum element from an unsorted
list?
a) Insertion Sort
b) Merge Sort
c) Selection Sort
d) Quick Sort
Answer: c) Selection Sort
5. What is the average time complexity of insertion sort?
a) O(1)
b) O(n)
c) O(n log n)
d) O(n^2)
Answer: d) O(n^2)
Moderate Level:
6. Which sorting algorithm divides the array into two halves, sorts them, and then
merges them?
a) Selection Sort
b) Insertion Sort
c) Merge Sort
d) Quick Sort
Answer: c) Merge Sort
7. In quicksort, which of the following operations is used to partition the array?
a) Selecting a pivot element
b) Merging two halves
c) Swapping adjacent elements
d) Selecting the maximum element
Answer: a) Selecting a pivot element
8. What is the worst-case time complexity of quicksort?
a) O(n log n)
b) O(n)
c) O(n^2)
d) O(log n)
Answer: c) O(n^2)
9. Which sorting algorithm is considered the best for partially sorted data?
a) Merge Sort
b) Quick Sort
c) Insertion Sort
d) Shell Sort
Answer: c) Insertion Sort
10. What is the time complexity of merge sort in the worst case?
a) O(n)
b) O(n log n)
c) O(n^2)
d) O(log n)
Answer: b) O(n log n)
Hard Level:
11. Which of the following sorting algorithms is not a comparison-based sort?
a) Quick Sort
b) Merge Sort
c) Heap Sort
d) Counting Sort
Answer: d) Counting Sort
12. What is the key characteristic of shell sort compared to other sorting algorithms?
a) It always uses the same gap size for comparisons
b) It uses insertion sort with a variable gap size
c) It sorts only in ascending order
d) It is a stable sorting algorithm
Answer: b) It uses insertion sort with a variable gap size
13. In terms of sorting stability, which of the following algorithms is stable?
a) Quick Sort
b) Selection Sort
c) Merge Sort
d) Heap Sort
Answer: c) Merge Sort
14. What is the average case time complexity of selection sort?
a) O(n)
b) O(n log n)
c) O(n^2)
d) O(log n)
Answer: c) O(n^2)
15. In binary search, what condition must be true for the algorithm to function
correctly?
a) The array must be sorted in ascending order
b) The array must be sorted in descending order
c) The array can be unsorted
d) The array can contain duplicate values
Answer: a) The array must be sorted in ascending order
Module 6:
Graphs: Introduction to graphs, Definition, Terminology, Directed, Undirected &
Weighted graph, Representation of graphs, Graph Traversal: Depth first search and
Breadth first search. Spanning Trees, minimum spanning Tree, Shortest path algorithm.
Easy Level:
1. What is a graph in the context of data structures?
a) A tree with only one node
b) A collection of nodes and edges connecting them
c) A list of sorted elements
d) A data structure for storing stacks
Answer: b) A collection of nodes and edges connecting them
2. In a directed graph, how do edges behave?
a) They can point in both directions between nodes
b) They point in only one direction between nodes
c) Edges are not present
d) Edges are always weighted
Answer: b) They point in only one direction between nodes
3. What is the difference between a directed and undirected graph?
a) Directed graphs have arrows on edges; undirected do not
b) Undirected graphs are always weighted
c) Directed graphs have no edges
d) Both are the same
Answer: a) Directed graphs have arrows on edges; undirected do not
4. Which graph traversal technique uses a queue?
a) Depth First Search (DFS)
b) Breadth First Search (BFS)
c) In-order traversal
d) Post-order traversal
Answer: b) Breadth First Search (BFS)
5. Which of the following is a property of a spanning tree?
a) It contains cycles
b) It connects all vertices with the minimum number of edges
c) It does not include all vertices
d) It is only used in undirected graphs
Answer: b) It connects all vertices with the minimum number of edges
Moderate Level:
6. What is the time complexity of Depth First Search (DFS) in a graph with VVV
vertices and EEE edges?
a) O(V)
b) O(E)
c) O(V + E)
d) O(E log V)
Answer: c) O(V + E)
7. In the adjacency matrix representation of a graph, what does the entry at position (i,
j) represent?
a) The number of nodes in the graph
b) Whether there is an edge between vertices i and j
c) The number of edges between vertices i and j
d) The weight of the graph
Answer: b) Whether there is an edge between vertices i and j
8. What is a minimum spanning tree (MST) in a weighted graph?
a) A tree with the fewest nodes
b) A tree with the maximum sum of edge weights
c) A tree connecting all vertices with the minimum sum of edge weights
d) A tree that includes only weighted edges
Answer: c) A tree connecting all vertices with the minimum sum of edge weights
9. Which of the following algorithms is commonly used to find the shortest path in a
weighted graph?
a) Kruskal’s algorithm
b) Prim’s algorithm
c) Dijkstra’s algorithm
d) Floyd-Warshall algorithm
Answer: c) Dijkstra’s algorithm
10. How many spanning trees can a complete graph with nnn vertices have?
a) n2n^2n2
b) nn−2n^{n-2}nn−2
c) 2n2^n2n
d) n⋅(n−1)n \cdot (n-1)n⋅(n−1)
Answer: b) nn−2n^{n-2}nn−2
Hard Level:
11. Which algorithm is used to find the minimum spanning tree in a graph?
a) Dijkstra's algorithm
b) Kruskal's algorithm
c) Bellman-Ford algorithm
d) DFS
Answer: b) Kruskal's algorithm
12. In a directed graph, what does it mean if a node has an out-degree of 0?
a) The node has no incoming edges
b) The node has no outgoing edges
c) The node is not connected to the graph
d) The node is part of a cycle
Answer: b) The node has no outgoing edges
13. What is the time complexity of Prim’s algorithm using an adjacency matrix?
a) O(V^2)
b) O(VE)
c) O(E log V)
d) O(V log E)
Answer: a) O(V^2)
14. In Dijkstra's algorithm, how are the shortest path estimates updated?
a) By exploring all edges at once
b) By exploring the nearest unvisited vertex
c) By updating the estimates only at the end of the algorithm
d) By visiting all vertices in increasing order of edge weight
Answer: b) By exploring the nearest unvisited vertex
15. Which graph traversal technique can be used to check if a graph is acyclic?
a) Depth First Search (DFS)
b) Breadth First Search (BFS)
c) Kruskal’s algorithm
d) Prim’s algorithm
Answer: a) Depth First Search (DFS)
Module 7:
Hashing: Definition, Hashing functions, Load factor and collision, open addressing (linear
probing) and chaining method to avoid collision.
Easy Level:
1. What is hashing primarily used for?
a) Sorting data
b) Storing data
c) Mapping data to a fixed-size value
d) Encrypting data
Answer: c) Mapping data to a fixed-size value
2. What does a hash function do?
a) Sorts the data
b) Compresses the data
c) Transforms input data into a fixed-size string of characters
d) Encrypts the data
Answer: c) Transforms input data into a fixed-size string of characters
3. What is a collision in hashing?
a) When two different keys generate the same hash value
b) When a key is not found in the hash table
c) When the load factor exceeds a certain threshold
d) When a hash table is resized
Answer: a) When two different keys generate the same hash value
4. In a hash table, what does the load factor represent?
a) The maximum number of elements allowed in the table
b) The ratio of the number of elements in the table to the size of the table
c) The number of collisions in the table
d) The efficiency of the hash function
Answer: b) The ratio of the number of elements in the table to the size of the table
5. Which method is used to handle collisions by storing entries in the next available
slot?
a) Chaining
b) Open addressing
c) Quadratic probing
d) Hashing
Answer: b) Open addressing
Moderate Level:
6. What is linear probing in open addressing?
a) Storing multiple values at the same index
b) Searching for the next available slot in a sequential manner
c) Using a secondary hash function to resolve collisions
d) Randomly selecting a new index
Answer: b) Searching for the next available slot in a sequential manner
7. What is the main disadvantage of chaining as a collision resolution method?
a) It requires more memory
b) It is less efficient than open addressing
c) It increases the load factor
d) It cannot handle collisions
Answer: a) It requires more memory
8. What happens when the load factor of a hash table exceeds a certain threshold?
a) The hash table is deleted
b) The hash table is resized and rehashed
c) New entries cannot be added
d) The hash function changes
Answer: b) The hash table is resized and rehashed
9. Which of the following is a good property of a hash function?
a) It should be easy to compute
b) It should generate a unique hash for every input
c) It should minimize collisions
d) Both a and c
Answer: d) Both a and c
10. In the chaining method of collision resolution, what data structure is commonly
used to store multiple entries at the same index?
a) Stack
b) Queue
c) Linked List
d) Array
Answer: c) Linked List
Hard Level:
11. Which of the following hash functions is considered to be a non-cryptographic hash
function?
a) SHA-256
b) MD5
c) MurmurHash
d) AES
Answer: c) MurmurHash
12. What is the time complexity for searching in a hash table with chaining under
average conditions?
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: a) O(1)
13. When using open addressing, which of the following probing techniques can be used
to reduce clustering?
a) Linear probing
b) Quadratic probing
c) Double hashing
d) Both b and c
Answer: d) Both b and c
14. What is a primary disadvantage of using open addressing?
a) It cannot handle large datasets
b) It leads to clustering
c) It requires more memory than chaining
d) It is more complex to implement
Answer: b) It leads to clustering
15. What is the expected number of probes for successful search in a hash table with a
load factor of α (alpha)?
a) O(1)
b) O(α)
c) O(1/α)
d) O(α log n)
Answer: b) O(α)