Data Structures and Algorithms MCQs
Data Structures and Algorithms MCQs
A) To store and organize data for efficient access and modification. (Correct
Answer)
2. Which data structure follows the First In, First Out (FIFO) principle?
A) Stack
C) Linked List
D) Tree
3. What is the time complexity of the binary search algorithm in the worst-case scenario?
A) O(n)
C) O(n^2)
D) O(1)
A) Breadth-First Search
B) Depth-First Search
D) MergeSort
A) Stack
B) Queue
D) Linked List
A) Leaf
B) Root
C) Sink
10. Which search algorithm works by repeatedly dividing the search space in half?
A) Linear Search
C) Depth-First Search
D) Breadth-First Search
B) A sequence of vertices and edges that begins and ends at the same vertex.
(Correct Answer)
D) A disconnected subgraph.
13. Which sorting algorithm has a time complexity of O(n log n) in the average and worst-
case scenarios?
A) Bubble Sort
B) Insertion Sort
D) Selection Sort
15. What is the term for the process of converting a higher-level programming language
code into machine code?
B) Interpretation
C) Execution
D) Debugging
A) Pop
B) Push
C) Insert
17. What is the primary advantage of using a hash table for data storage?
A) Linked List
B) Array
D) Tree
20. What is the primary purpose of the Bellman-Ford algorithm in graph theory?
D) To find the shortest path between a source vertex and all other vertices in a
weighted graph. (Correct Answer)
21. Which algorithm is used to find the strongly connected components in a directed graph?
A) Dijkstra's Algorithm
B) Floyd-Warshall Algorithm
D) Prim's Algorithm
B) To sort elements based on their most significant digit first. (Correct Answer)
23. What is the time complexity of the quicksort algorithm in the average case?
A) O(n)
B) O(log n)
C) O(n^2)
C) A graph where vertices can be colored with two colors such that no two
adjacent vertices have the same color. (Correct Answer)
25. What is the primary purpose of the Breadth-First Search (BFS) algorithm?
D) To explore all vertices at the current depth before moving on to the next depth.
(Correct Answer)
A) A strategy that always chooses the most promising option at each step.
(Correct Answer)
B) Topological sorting.
C) Minimum spanning tree construction. (Correct Answer)
D) Depth-First Search.
28. What is the time complexity of the merge sort algorithm in the worst-case scenario?
A) O(n)
B) O(log n)
C) O(n^2)
29. Which algorithm is used to find the shortest path between all pairs of vertices in a
weighted graph?
A) Dijkstra's Algorithm
B) Bellman-Ford Algorithm
D) Kruskal's Algorithm
30. What is the term for a directed acyclic graph used to represent dependencies between
tasks?
A) Binary Tree
B) Heap
D) AVL Tree
31. Which algorithm is used for searching an element in an ordered list by repeatedly
dividing the search range in half?
A) Linear Search
C) Depth-First Search
D) Breadth-First Search
C) To explore all vertices at the current depth before moving on to the next depth.
D) To find the shortest path in a graph considering both the cost to reach the
current vertex and an estimate of the cost to reach the goal. (Correct Answer)
33. Which of the following is a valid application of the Depth-First Search (DFS) algorithm?
D) Dijkstra's Algorithm.
34. What is the primary purpose of the topological sort algorithm in graph theory?
D) To linearly order the vertices in a directed acyclic graph (DAG) respecting their
dependencies. (Correct Answer)
A) Array
B) Linked List
D) Stack
D) To find the shortest path between all pairs of vertices in a weighted graph.
(Correct Answer)
37. What is the time complexity of the bubble sort algorithm in the worst-case scenario?
A) O(n)
B) O(log n)
D) O(1)
38. In the context of algorithms, what is the term for a set of rules that govern the
sequence of steps to solve a problem?
A) Syntax
B) Semantics
D) Variable
40. What is the term for a collection of nodes where each node points to the next node in
the sequence?
A) Stack
B) Queue
D) Tree
41. What is the time complexity of the selection sort algorithm in the worst-case scenario?
A) O(n)
B) O(log n)
D) O(1)
A) An algorithm that always chooses the most promising option at each step.
(Correct Answer)
44. In graph theory, what is the term for the process of visiting all the vertices of a graph
without revisiting any vertex?
A) Pathfinding
B) Cycle detection
C) Traversal
B) Topological sorting.
47. What is the time complexity of the insertion sort algorithm in the worst-case scenario?
A) O(n)
B) O(log n)
D) O(1)