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)
Answer: C) O(n^2)

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
Answer: B) Quick Sort

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

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

Which algorithm is used for finding the shortest path in a weighted graph?
A) Breadth-First Search (BFS)
B) Depth-First Search (DFS)
C) Dijkstra’s Algorithm
D) Prim’s Algorithm
Answer: C) Dijkstra’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)
Answer: A) O(log n)

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
Answer: A) Fibonacci Sequence

Which sorting algorithm is considered stable?
A) Quick Sort
B) Merge Sort
C) Heap Sort
D) Shell Sort
Answer: B) Merge 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)
Answer: B) O(n 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
Answer: B) Prim’s Algorithm

Which of the following is an example of a greedy algorithm?
A) Dijkstra’s Algorithm
B) Merge Sort
C) Bubble Sort
D) Breadth-First Search
Answer: A) Dijkstra’s Algorithm

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

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)
Answer: C) O(n^2)

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

Which algorithm is used for topological sorting?
A) Depth-First Search
B) Breadth-First Search
C) Dijkstra’s Algorithm
D) Kahn’s Algorithm
Answer: 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)
Answer: C) O(n^2)

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

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)
Answer: B) O(n log n)

Which of the following algorithms is NOT a comparison-based sorting algorithm?
A) Merge Sort
B) Quick Sort
C) Radix Sort
D) Heap Sort
Answer: C) Radix 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
Answer: C) Bellman-Ford 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)
Answer: B) O(n log n)

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

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)
Answer: 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
Answer: B) Ford-Fulkerson 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)
Answer: 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
Answer: C) Bellman-Ford 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)
Answer: B) O(n log n)

Which of the following algorithms is used for finding the longest common subsequence of two sequences?
A) Breadth-First Search
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)
Answer: C) O(n^2)

Which of the following is NOT a searching algorithm?
A) Binary Search
B) Depth-First Search
C) Breadth-First Search
D) Merge Sort
Answer: 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)
Answer: 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
D) Breadth-First Search
Answer: A) Dijkstra’s Algorithm

Which sorting algorithm is considered stable?
A) Quick Sort
B) Merge Sort
C) Heap Sort
D) Shell Sort
Answer: B) Merge 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)
Answer: C) O(n^2)

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
Answer: B) Prim’s Algorithm

Which of the following is NOT a stable sorting algorithm?
A) Quick Sort
B) Merge Sort
C) Insertion Sort
D) Bubble Sort
Answer: A) Quick 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)
Answer: B) O(n log n)

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

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

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)
Answer: C) O(n^2)

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
Answer: C) Bellman-Ford 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)
Answer: B) O(n log n)

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

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)
Answer: 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
Answer: B) Ford-Fulkerson 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)
Answer: 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
Answer: C) Bellman-Ford 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)
Answer: B) O(n log n)

Which of the following algorithms is used for finding the longest common subsequence of two sequences?
A) Breadth-First Search
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)
Answer: C) O(n^2)

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button