Algorithms and Complexity MCQs (Part-3)

What does Big O notation measure?

A Execution time
B Memory usage
C Input size
D Worst-case complexity

Which algorithm is used for finding the minimum spanning tree in a graph?

A Dijkstra’s Algorithm
B Bellman-Ford
C Prim’s Algorithm
D Floyd-Warshall

Which time complexity does Merge Sort have?

A O(n^2)
B O(n log n)
C O(n)
D O(log n)

What does space complexity refer to?

A Memory required by algorithm
B Time taken by algorithm
C Input size
D Worst-case time

Which algorithm is typically used for shortest path calculation in weighted graphs?

A Merge Sort
B Quick Sort
C Bellman-Ford
D Binary Search

What is the best-case time complexity of Binary Search?

A O(n)
B O(log n)
C O(n log n)
D O(1)

What is the characteristic of a backtracking algorithm?

A Always finds optimal solutions
B Avoids recursion
C Focuses on greedy choices
D Explores all possible solutions

What does the term “NP-Hard” refer to?

A Problems at least as hard as NP-complete
B Problems solvable in polynomial time
C Problems with exponential time complexity
D Problems not in NP

Which of the following sorting algorithms is not stable?

A Merge Sort
B Insertion Sort
C Quick Sort
D Bubble Sort

Which type of algorithm is used for finding the longest common subsequence?

A Divide and conquer
B Greedy algorithm
C Brute force
D Dynamic programming

What is the primary advantage of a greedy algorithm?

A Simple to implement
B Always gives optimal solution
C Requires no recursion
D Always faster than other algorithms

What is the time complexity of an insertion sort algorithm in the worst case?

A O(n log n)
B O(n)
C O(n^2)
D O(log n)

Which algorithm is best suited for solving problems involving optimal substructure?

A Greedy algorithms
B Dynamic programming
C Divide and conquer
D Randomized algorithms

Which of the following is true about Dijkstra’s algorithm?

A Works for negative edges
B Solves the maximum flow problem
C Uses backtracking
D Solves the shortest path problem

What is the best sorting algorithm for a small dataset?

A Bubble Sort
B Quick Sort
C Merge Sort
D Heap Sort