retagged by
1,067 views
0 votes
0 votes
I mean i guess it should be in O(n/2) i.e. O(n) time. Because one must check for every element starting from the first one till n/2 th element & for each of which one must whether A[i]==A[n/2 +i].

Please explain.
related to an answer for: GATE CSE 2008 | Question: 40
retagged by

1 Answer

2 votes
2 votes
Let for a particular index i check that condition A[i]==A[i+1] or not..
 if it is true then (check A[2i]==A[n/2+1] or not )
else select i+1 for same purpose..

let size of array is 100 and A[0]=A[2]=A[4]!=A[8]
then dont check for A[2] as well as A[4]..
this ll reduce no of comparison to logn..
edited by

Related questions

0 votes
0 votes
0 answers
2
usdid asked Apr 16, 2022
276 views
a) what is the iterative equation showing the running time of the algorithm whose pseudocode is given below? b) What is this repeated equation in asymptotic notation usin...
2 votes
2 votes
2 answers
3
Vikrant Singh asked Jan 31, 2015
1,726 views
What is the worst case time complexity to find the gcd(m,n) using best algorithm known?A. O(log(min(m,n)))B, O(log(max(m,n)))