COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]


Best case


Worst case


Average case


None of the above

Detailed explanation1: Best case is the function which performs the minimum number of steps on input data of n elements. Worst case is the function which performs the maximum number of steps on input data of size n. Average case is the function which performs an average number of steps on input data of n elements.
Detailed explanation2: Best case = fastest time to complete, with optimal inputs chosen. For example, the best case for a sorting algorithm would be data that’s already sorted. Worst case = slowest time to complete, with pessimal inputs chosen.
Detailed explanation3: Insertion sort is an inplace sorting algorithm, meaning no auxiliary data structures, the algorithm performs only swaps within the input array. So the space complexity is O(1). In spacewise insertion sort is better.
Detailed explanation4: The time complexity of Quicksort is O(n log n) in the best case, O(n log n) in the average case, and O(n^2) in the worst case. But because it has the best performance in the average case for most inputs, Quicksort is generally considered the “fastest” sorting algorithm.