The Gateway to Computer Science Excellence
0 votes
111 views

Which of the below given sorting techniques has highest best-case runtime complexity.
(A) Quick sort

(B) Selection sort
(C) Insertion sort

(D) Bubble sort


Answer: (B)

Explanation:
Quick sort best case time complexity is Ο(n logn)
Selection sort best case time complexity is Ο(n^2 )

Insertion sort best case time complexity is Ο(n)

Bubble sort best case time complexity is Ο(n)

Source: GeeksforGeeks

https://www.geeksforgeeks.org/gate-gate-mock-2017-question-12/

I did not understand this as best case time should be O(n) sorting method what does highest best cases mean?

in Algorithms by Active (2.5k points) | 111 views
0

Highest { best-case runtime (for that algorithm!) } complexity is the one which takes the longest time to complete. The question wants you to find the highest, which is the slowest algorithm from the options. So, it is obviously it is $O(n^2)$.

0
There is no meaning for highest best case. 
Quick sort best case complexity O(nlogn)
Insertion sort best case: O(n), If, all elements are already sorted order then it gives result O(n)
Bubble sort best case: O(n), If, all elements are already sorted order then it gives result O(n)

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,291 answers
198,209 comments
104,892 users