Algorithms MCQ
Our website offers a collection of Algorithms MCQs to help learners practice and understand important computer science concepts. The questions cover topics like sorting, searching, recursion, dynamic programming, graph theory, and complexity analysis. Each MCQ is made to test knowledge and improve problem-solving skills. Clear explanations are provided with answers so learners can easily understand their mistakes. This platform is helpful for students, professionals, and interview candidates, making algorithm preparation easier and more effective.
Q1. Which of the following is the time complexity of binary search algorithm?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(1)
📘 View Explanation
Q2. Which sorting algorithm has the best average case time complexity?
A. Bubble Sort
B. Insertion Sort
C. Merge Sort
D. Selection Sort
📘 View Explanation
Q3. In a graph, which traversal technique uses a queue?
A. Depth First Search (DFS)
B. Breadth First Search (BFS)
C. Dijkstra’s Algorithm
D. Prim’s Algorithm
📘 View Explanation
Q4. Which data structure is used in a recursive function call?
A. Queue
B. Stack
C. Linked List
D. Heap
📘 View Explanation
Q5. What is the time complexity of binary search algorithm?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(1)
📘 View Explanation
Q6. Which sorting algorithm has the best average-case performance?
A. Bubble Sort
B. Quick Sort
C. Selection Sort
D. Insertion Sort
📘 View Explanation
Q7. Dijkstra’s algorithm is used to solve:
A. Minimum spanning tree
B. All-pairs shortest path
C. Single-source shortest path
D. Maximum flow
📘 View Explanation
Q8. Which data structure is used in Depth First Search (DFS)?
A. Queue
B. Stack
C. Heap
D. Priority Queue
📘 View Explanation
Q9. Which of the following has the worst-case time complexity O(n^2)?
A. Merge Sort
B. Heap Sort
C. Bubble Sort
D. Quick Sort
📘 View Explanation
Q10. What is the space complexity of Merge Sort?
A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
📘 View Explanation
Q11. Which algorithm is commonly used for finding Minimum Spanning Tree?
A. Dijkstra’s algorithm
B. Prim’s algorithm
C. Floyd-Warshall algorithm
D. Bellman-Ford algorithm
📘 View Explanation
Q12. Which searching algorithm is best for unsorted data?
A. Binary Search
B. Jump Search
C. Linear Search
D. Exponential Search
📘 View Explanation
Q13. What is the time complexity of Heap Sort?
A. O(n)
B. O(n log n)
C. O(log n)
D. O(n^2)
📘 View Explanation
Q14. The Knuth-Morris-Pratt (KMP) algorithm is used for:
A. Sorting numbers
B. Finding shortest path
C. String pattern matching
D. Matrix multiplication
📘 View Explanation
Q15. Which traversal is used in Breadth First Search (BFS)?
A. Inorder
B. Level order
C. Postorder
D. Preorder
📘 View Explanation
Q16. Which algorithm is used for solving the all-pairs shortest path problem?
A. Dijkstra’s algorithm
B. Floyd-Warshall algorithm
C. Kruskal’s algorithm
D. Prim’s algorithm
📘 View Explanation
Q17. Which of the following problems is NP-complete?
A. Binary Search
B. Traveling Salesman Problem
C. Merge Sort
D. Prim’s Algorithm
📘 View Explanation
Q18. Which sorting algorithm is stable?
A. Quick Sort
B. Merge Sort
C. Heap Sort
D. Selection Sort
📘 View Explanation
Q19. Which algorithm is used in operating systems for deadlock detection?
A. Dijkstra’s algorithm
B. Banker’s algorithm
C. Bellman-Ford algorithm
D. Kruskal’s algorithm
📘 View Explanation
Q20. What is the best-case time complexity of Quick Sort?
A. O(n)
B. O(n log n)
C. O(n^2)
D. O(log n)
📘 View Explanation
Q21. Which graph traversal guarantees finding the shortest path in an unweighted graph?
A. DFS
B. BFS
C. Dijkstra’s algorithm
D. Prim’s algorithm
📘 View Explanation
Q22. What is the recurrence relation for Merge Sort?
A. T(n) = T(n-1) + O(1)
B. T(n) = 2T(n/2) + O(n)
C. T(n) = T(n/2) + O(1)
D. T(n) = T(n/2) + O(n)
📘 View Explanation
Q23. Which algorithm uses dynamic programming to solve shortest path problems?
A. Bellman-Ford algorithm
B. Dijkstra’s algorithm
C. Kruskal’s algorithm
D. Prim’s algorithm
📘 View Explanation
Q24. Which of the following is a divide and conquer algorithm?
A. Quick Sort
B. Bubble Sort
C. Selection Sort
D. Linear Search
📘 View Explanation
Q25. What is the time complexity of binary search algorithm?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(1)
📘 View Explanation
Q26. Which sorting algorithm has the best average-case performance?
A. Bubble Sort
B. Quick Sort
C. Selection Sort
D. Insertion Sort
📘 View Explanation
Q27. Dijkstra’s algorithm is used to solve:
A. Minimum spanning tree
B. All-pairs shortest path
C. Single-source shortest path
D. Maximum flow
📘 View Explanation
Q28. Which data structure is used in Depth First Search (DFS)?
A. Queue
B. Stack
C. Heap
D. Priority Queue
📘 View Explanation
Q29. Which of the following has the worst-case time complexity O(n^2)?
A. Merge Sort
B. Heap Sort
C. Bubble Sort
D. Quick Sort
📘 View Explanation
Q30. What is the space complexity of Merge Sort?
A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
📘 View Explanation