@empo I believe you missed the point where Dave is setting arr[0] as elem.
So this while condition will break at size = 0.
Thanks
Sachin
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://group
@Rafi: Try this:
int arrExsits( int* arr, int size, int elem)
{
int temp = arr[0];
arr[0] = elem;
while( arr[--size] != elem );
arr[0] = temp;
return a[size] == elem ? size : -1;
}
n+1 comparisons, and it leaves the array unaltered.
Dave
On Sunday, September 30, 2012 4:27:2