Practice free →
HomeGATE CSEcomputerscienceAlgorithms › Worst-case running time of an algorithm on input…

Worst-case running time of an algorithm on input size n is

Athe average running time across all inputs of size n
Bthe running time on the smallest valid input
Cthe maximum running time over all inputs of size n
Dthe running time when the input is already sorted
Answer & Solution
Correct answer: C. the maximum running time over all inputs of size n
Worst case is the maximum over all inputs of size n. It is the true upper bound: on ANY valid input the algorithm runs no slower than this. Average needs a probability distribution; smallest input is unrelated; already-sorted is a specific best/worst case for some algorithms (best for insertion sort, worst for quicksort with naive pivot).
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions