Complete the following table by specifying algorithm efficiency for : Selection sort, Insertion sort, Binary search, and Linear search. (Efficiency can be one of : log n, n, n^{2}). List algorithms from the most efficient (fastest) to the least efficient (slowest).
ALGORITHM 
EFFICENCY 

1 most efficient (fastest) 

2 

3 

4 least efficient (slowest) 
(Most Efficient)
1.Binary Search
Complexity log n
2. Linear Search
Complexity n
3. Insertion Sort
Complexity  n^{2}
4.Selection Sort
Complexity  n^{2}
(Least Efficient)
Reason for the above order:
for 3rd and 4th position, Insertion Sort is better than Selection Sort because the best case complexity of Selection Sort is O(n^{2}) where as Insertion Sort is O(n).
for 3rd and 2nd position, Linear Search WorstCase Complexity is O(n) as it just needs a single for loop for searching where as worst case complexity ofinsertion sort is O(n^{2})
for 2nd and 1st position, Binary search searches an element in maximum log(n) time as it uses divide and conquer whereas linear search takes O(n) time.
I hope I solved your query. In the case of doubt feel free to ask in the comment section.
Get Answers For Free
Most questions answered within 1 hours.