Imagine you have an array with 1000 numbers in it: 1, 3, 4, 5, etc. Then you attempt to search for 2. When you get to 3 (the second element) you know that 2 is not in the array. However your code...
Type: Posts; User: Junky
Imagine you have an array with 1000 numbers in it: 1, 3, 4, 5, etc. Then you attempt to search for 2. When you get to 3 (the second element) you know that 2 is not in the array. However your code...
That still does not address my second point.
That has addressed my first point but not my second point.
Make the inner if statement the first thing the code does in the loop. Why do anything else when you have found the number?
Stop searching as soon as the value in the array is larger than the...