Okay, I know this is probably really simple. I know how to find max/min in an unsorted array, but what about if the array is sorted? Is it the same thing as this, in an unsorted array:
Or is there a simpler way than going through all that when the array is sorted? Would it be a binary search or what? How would I go about doing it?Code:int smallest (int arr [], int num) { int smallestsofar = arr [0]; for (int count = 1; count < num; count++) { if (smallestsofar > arr [count]) smallestsofar = arr [count]; } return smallestsofar; }