this finds first and last index in pair structure in logn
void repindxs(int array[],int start, int end, int k, pairint, int *p, int
n/*last index*/)
{
if(startend) return ;
int m = (start+end)/2;
if( array[m] == k (m-10?-1:array[m-1] k) )
p-first = m;
else if(array[m] k || (array[m]==k
How to find the indexes of a repeated element in the sorted array in
*log n*time..
e.g.
a: 1 3 4 4 5 6 7 8 8 9 9 9 10
x=9
ouput is 10 and 12 (indexing from 1)
--
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in
--
You received this message because you are
Using binary search, first find the first occurrence of x. Using this first
occurrence run another binary search to find the last occurrence of x.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Suppose the array is not sorted and we have to find if an element has
occurred earlier or not; and if yes, then remove
it.what is the best achievable time and how?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.