Question: How to find the smallest element in rotated sorted array?

Input 1: array[]={4,5,6,7,8,9,1,2,3};
Output : position of smallest element means here 6 (array starts from zero).

Input 2: array[]={1,2,3,4,5,6,7,8,9};
Output : position of smallest element means here 0 (array starts from zero).

Solution: #include
int find_smallest_element_position(int *a, int first , int last);
main()
{
int a[10]={4,5,6,7,8,9,1,2,3};
int pos;
pos=find_smallest_element_position(a,0,8);
printf("The smallest element's position is %d\n",pos);
}

int find_smallest_element_position(int *a, int first , int last)
{
int mid;
while(first {
mid=(first+last)/2;
if(a[mid]>a[last])
{
first=mid+1;
}
else
{
last=mid;
}
}
return first;
}