Pivot of sorted and rotated array_


no output on both test cases

@p45s99tik hey pratik do like this
if(a[s]>=a[mid]){ //left part will be unsorted and pivot will lie in left part
e=mid-1;
}
else{
s=mid+1;
}

hey,
can you please tell me why the error occured
i tried some test cases on previous code and it gave correct output except when pivot is at index
0

@p45s99tik hey pratik try dry run on this case
15
20 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
you will find that your code will not work because when e=mid-1 is calculate then your next statement will check for
if(a[e]<=a[mid]){ //right part will be unosorted and pivot will be in right part
s=mid+1;
}
which is wrong
you have to use else statement if above statement satisfies your mid will shift in the wrong place.

thanks for clarification.