Algorithm Complexity & Big O Notation MCQs with Answers
What does Big O notation describe in algorithm analysis?
a) The best-case performance of an algorithm
b) The exact runtime of an algorithm
c) The worst-case or upper bound performance of an algorithm
d) The memory usage of an algorithm
Which of the following represents constant time complexity?
a) O(n)
b) O(1)
c) O(n²)
d) O(log n)
What is the time complexity of binary search?
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)
Which of the following complexities grows the fastest as input size increases?
a) O(n)
b) O(log n)
c) O(n²)
d) O(2ⁿ)
If an algorithm has a time complexity of O(n²), what happens when the input size doubles?
a) Execution time doubles
b) Execution time quadruples
c) Execution time remains the same
d) Execution time increases logarithmically
Which of the following is the best time complexity?
a) O(n²)
b) O(n log n)
c) O(n)
d) O(1)
Which notation represents linear time complexity?
a) O(n)
b) O(log n)
c) O(n²)
d) O(1)
What is the worst-case time complexity of QuickSort?
a) O(n²)
b) O(n log n)
c) O(n)
d) O(log n)
What is the best-case time complexity of Merge Sort?
a) O(n²)
b) O(n log n)
c) O(n)
d) O(1)
Which algorithm has the best time complexity for searching an element in a sorted array?
a) Linear search
b) Bubble sort
c) Binary search
d) Selection sort
Which of the following complexities is considered the most efficient?
a) O(1)
b) O(n)
c) O(n²)
d) O(2ⁿ)
Which complexity class represents an algorithm that doubles its operations with each increase in input size?
a) O(n)
b) O(log n)
c) O(2ⁿ)
d) O(n log n)
If an algorithm has a time complexity of O(log n), how does execution time change when input size increases?
a) Increases exponentially
b) Doubles
c) Increases logarithmically
d) Remains constant
Which of the following sorting algorithms has an average time complexity of O(n log n)?
a) Bubble Sort
b) QuickSort
c) Insertion Sort
d) Selection Sort
Which of the following is an example of polynomial time complexity?
a) O(n log n)
b) O(n²)
c) O(2ⁿ)
d) O(log n)
What is the time complexity of iterating over a 2D matrix of size n × n?
a) O(n)
b) O(n²)
c) O(n log n)
d) O(1)
Which of the following complexities represents exponential growth?
a) O(n log n)
b) O(n²)
c) O(2ⁿ)
d) O(n)
What is the best-case time complexity of insertion sort?
a) O(n²)
b) O(n)
c) O(n log n)
d) O(1)
Which of the following describes the space complexity of an algorithm?
a) The time taken by the algorithm to execute
b) The amount of extra memory required by the algorithm
c) The number of recursive calls made
d) The number of iterations in a loop
What is the worst-case time complexity of Bubble Sort?
a) O(n)
b) O(n log n)
c) O(n²)
d) O(1)
Which notation represents logarithmic time complexity?
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)
What is the time complexity of traversing a linked list?
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Which algorithm has a time complexity of O(n log n) in its best, average, and worst cases?
a) QuickSort
b) Merge Sort
c) Bubble Sort
d) Selection Sort
Which sorting algorithm is most efficient for nearly sorted data?
a) Bubble Sort
b) Insertion Sort
c) Merge Sort
d) QuickSort
What is the space complexity of Merge Sort?
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Which of the following complexities represents quadratic growth?
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)
What is the worst-case time complexity of searching an element in an unsorted array?
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Which of the following complexities is considered infeasible for large inputs?
a) O(n)
b) O(log n)
c) O(2ⁿ)
d) O(n log n)
What is the average-case time complexity of linear search?
a) O(n)
b) O(n log n)
c) O(log n)
d) O(1)