Every computer program is based on some sequence of steps or plans ,what we say as algorithms.
We can design algorithms for a problem / program in multiple ways , but we cannot assure that every algorithm that we create for a problem will be the best !
While making algorithms we should think of program in a real time scenario where program will consume :
- Memory
- Time and other resources of a computer
The conditions in which the resources are least utilized we call them as best case .
For example , if you need to search an item and if the item is available in first index then this ll be best case !
Find some examples of best cases in sort as below :
Algorithm |
Time Complexity:Best |
Quick Sort |
O(n log(n)) |
Merge sort |
O(n log(n)) |
Heap sort |
O(n log(n)) |
Smooth sort |
O(n) |
Bubble sort |
O(n) |
Insertion sort |
O(n) |
Selection sort |
O(n^{2}) |