• retagged by
582 views
0 0 votes

There is a sorted array which is of very large size. In those elements every element are repeated more than once except one element. How much time it will take to find that element?

  • O(1)

  • O(n)

  • O(nlogn)

  • O(logn)

I think its less than O(log n) (divide n conquer) but solution is O(n) 

1 Answer

0 0 votes
Answer will be O(n) by divide and conquer also...

f(n)

{

O(1); //checking with center element

f(n/2); //for left half of array

f(n/2); //for right half of array.

}
Position:
Show:

Related questions

2 2 votes
3 3 answers
2.1k
2.1k views
gari asked Jun 21, 2017
2,140 views
How many comparisons are there for finding any second element that is neither minimum or maximum.10 5 50 70 80 2 3
3 3 votes
2 2 answers
3.4k
3.4k views
rahuldb asked May 10, 2017
3,386 views
Please show the workingConsider a Quick-sort algorithm that always selects $(n / 5)^{\text {th }}$ smallest as the pivot element using $\mathrm{O}(\mathrm{n})$ time algor...
6 6 votes
2 answers 2 answers
9.0k
9.0k views
worst_engineer asked Oct 7, 2015
9,017 views
In quick sort , for sorting n elements , the (n/4)th smallest element is selected as pivot using an O(n) time algorithm. What will be the time complexity?it is $\Theta (...
2 2 votes
1 1 answer
2.2k
2.2k views
yes asked Oct 6, 2015
2,216 views
for example array contain a[1 2 3 3 3 3 3 4 5] then retun(1)