vthe time complexity for bubble, insertion, selection, merge and quick sorts Flashcards
(18 cards)
What is the time complexity of bubble sort in the worst case?
O(n^2)
True or False: Insertion sort has a best case time complexity of O(n).
True
Fill in the blank: The average case time complexity for selection sort is ____.
O(n^2)
Which sorting algorithm has a worst case time complexity of O(n log n)?
Merge sort and Quick sort
What is the best case time complexity for merge sort?
O(n log n)
True or False: Quick sort can have a worst case time complexity of O(n^2).
True
What is the average case time complexity of bubble sort?
O(n^2)
In which sorting algorithm does the time complexity remain O(n^2) for both average and worst cases?
Selection sort
Fill in the blank: The time complexity of insertion sort in the worst case is ____.
O(n^2)
Which sorting algorithm is generally faster on average, quick sort or bubble sort?
Quick sort
What is the time complexity of quick sort in the average case?
O(n log n)
True or False: The time complexity of merge sort is always O(n log n).
True
Which sorting algorithm is stable: bubble sort or quick sort?
Bubble sort
What is the time complexity of insertion sort in the average case?
O(n^2)
Fill in the blank: The worst case time complexity for quick sort is ____.
O(n^2)
What is the primary advantage of merge sort over quick sort?
Merge sort is stable.
Which sorting algorithm is typically used for small data sets due to its simplicity?
Insertion sort
What is the time complexity of selection sort in the best case?
O(n^2)