retagged by
913 views
0 votes
0 votes

Which algorithm has same average, worst case and best case time ?

  1. Binary search
  2. Maximum of n number
  3. Quick sort
  4. Fibonacci search
retagged by

1 Answer

0 votes
0 votes
The answer should be B because all other methods have different time complexities if we consider their average, best, and worst case.

But in case of finding the maximum of n numbers- (Numbers are stored in an array at random order)

Worst Case: Maximum number is present at the end,

in this case, we have to go through all the elements in the array, so the time taken is to be $O(n)$

Average Case: Maximum number is in the middle,

here in this case too we need to go through all the elements in the array, even though it is in the middle but we do not know about it, so the time taken is to be $O(n)$

Best Case: The maximum number is at the first index.

in this case, too the total time taken is to be $O(n)$.

So the correct answer is  $B$.
edited by

Related questions

0 votes
0 votes
1 answer
1
go_editor asked Mar 27, 2020
2,373 views
Binary search tree is an example of :Divide and conquer techniqueGreedy algorithmBack trackingDynamic Programming
0 votes
0 votes
1 answer
2
go_editor asked Mar 27, 2020
1,531 views
Which of the regular expressions corresponds to this grammar ?$S → AB/AS, A → a/aA, B → b$$aa^*b^+$$aa^*b$$(ab)^*$$a(ab)^*$
0 votes
0 votes
1 answer
3
1 votes
1 votes
2 answers
4
go_editor asked Mar 27, 2020
12,214 views
The number of edges in a complete graph with $N$ vertices is equal to :$N (N−1)$$2N−1$$N−1$$N(N−1)/2$