Computer MCQs

# Computer Algorithms MCQs with Answer

What is the time complexity of the bubble sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following sorting algorithms has the best average-case time complexity?
A) Bubble Sort
B) Quick Sort
C) Insertion Sort
D) Selection Sort

What data structure does a depth-first search (DFS) use?
A) Queue
B) Stack
C) Heap
D) Array

Which of the following is a divide-and-conquer algorithm?
B) Quick Sort
C) Linear Search
D) Bubble Sort

Which algorithm is used for finding the shortest path in a weighted graph?
B) Depth-First Search (DFS)
C) Dijkstra’s Algorithm
D) Prim’s Algorithm

What is the worst-case time complexity of the binary search algorithm?
A) O(log n)
B) O(n)
C) O(n log n)
D) O(n^2)

Which of the following is an example of a dynamic programming problem?
A) Fibonacci Sequence
B) Binary Search
C) Bubble Sort
D) Depth-First Search

Which sorting algorithm is considered stable?
A) Quick Sort
B) Merge Sort
C) Heap Sort
D) Shell Sort

What is the time complexity of the merge sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which algorithm is used for finding the minimum spanning tree of a graph?
A) Dijkstra’s Algorithm
B) Prim’s Algorithm
C) Bellman-Ford Algorithm
D) Kruskal’s Algorithm

Which of the following is an example of a greedy algorithm?
A) Dijkstra’s Algorithm
B) Merge Sort
C) Bubble Sort

Which algorithm is used for finding the strongly connected components in a directed graph?
B) Depth-First Search
C) Dijkstra’s Algorithm
D) Bellman-Ford Algorithm

What is the worst-case time complexity of the selection sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following is NOT a stable sorting algorithm?
A) Quick Sort
B) Merge Sort
C) Insertion Sort
D) Bubble Sort

Which algorithm is used for topological sorting?
A) Depth-First Search
C) Dijkstra’s Algorithm
D) Kahn’s Algorithm

What is the worst-case time complexity of the quick sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which algorithm is used for finding the shortest path in an unweighted graph?
B) Depth-First Search
C) Dijkstra’s Algorithm
D) Bellman-Ford Algorithm

What is the time complexity of the shell sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following algorithms is NOT a comparison-based sorting algorithm?
A) Merge Sort
B) Quick Sort
D) Heap Sort

Which algorithm is used for finding the shortest path in a graph with negative edge weights?
A) Dijkstra’s Algorithm
B) Prim’s Algorithm
C) Bellman-Ford Algorithm
D) Kruskal’s Algorithm

What is the time complexity of the heap sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following algorithms is used for finding all simple cycles in a directed graph?
A) Depth-First Search
C) Bellman-Ford Algorithm
D) Floyd-Warshall Algorithm

What is the worst-case time complexity of the radix sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(kn)

Which algorithm is used for finding the maximum flow in a network?
A) Dijkstra’s Algorithm
B) Ford-Fulkerson Algorithm
C) Prim’s Algorithm
D) Bellman-Ford Algorithm

What is the time complexity of the counting sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(k+n)

Which algorithm is used for finding the shortest path in a weighted graph with negative edge weights?
A) Dijkstra’s Algorithm
B) Prim’s Algorithm
C) Bellman-Ford Algorithm
D) Kruskal’s Algorithm

What is the time complexity of the bucket sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(k+n)

Which of the following algorithms is used for finding the longest common subsequence of two sequences?
B) Depth-First Search
C) Bellman-Ford Algorithm
D) Longest Common Subsequence Algorithm
Answer: D) Longest Common Subsequence Algorithm

What is the worst-case time complexity of the bubble sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following is NOT a searching algorithm?
A) Binary Search
B) Depth-First Search
D) Merge Sort

What is the time complexity of the binary search algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following is an example of a greedy algorithm?
A) Dijkstra’s Algorithm
B) Merge Sort
C) Bubble Sort

Which sorting algorithm is considered stable?
A) Quick Sort
B) Merge Sort
C) Heap Sort
D) Shell Sort

What is the worst-case time complexity of the selection sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which algorithm is used for finding the minimum spanning tree of a graph?
A) Dijkstra’s Algorithm
B) Prim’s Algorithm
C) Bellman-Ford Algorithm
D) Kruskal’s Algorithm

Which of the following is NOT a stable sorting algorithm?
A) Quick Sort
B) Merge Sort
C) Insertion Sort
D) Bubble Sort

What is the time complexity of the shell sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following algorithms is NOT a comparison-based sorting algorithm?
A) Merge Sort
B) Quick Sort
D) Heap Sort

Which algorithm is used for finding the shortest path in an unweighted graph?
B) Depth-First Search
C) Dijkstra’s Algorithm
D) Bellman-Ford Algorithm

What is the worst-case time complexity of the quick sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which algorithm is used for finding the shortest path in a graph with negative edge weights?
A) Dijkstra’s Algorithm
B) Prim’s Algorithm
C) Bellman-Ford Algorithm
D) Kruskal’s Algorithm

What is the time complexity of the heap sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(log n)

Which of the following algorithms is used for finding all simple cycles in a directed graph?
A) Depth-First Search
C) Bellman-Ford Algorithm
D) Floyd-Warshall Algorithm

What is the worst-case time complexity of the radix sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(kn)

Which algorithm is used for finding the maximum flow in a network?
A) Dijkstra’s Algorithm
B) Ford-Fulkerson Algorithm
C) Prim’s Algorithm
D) Bellman-Ford Algorithm

What is the time complexity of the counting sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(k+n)

Which algorithm is used for finding the shortest path in a weighted graph with negative edge weights?
A) Dijkstra’s Algorithm
B) Prim’s Algorithm
C) Bellman-Ford Algorithm
D) Kruskal’s Algorithm

What is the time complexity of the bucket sort algorithm?
A) O(n)
B) O(n log n)
C) O(n^2)
D) O(k+n)

Which of the following algorithms is used for finding the longest common subsequence of two sequences?