What kind of search do you use: linear or binary for each scenario?
Review questions:
What does the code do if int[ ] nums = { 7,26,45,189}? public static void mystery (int nums[]){
for (int i =0; i < nums.length; i += 2)
nums[i] /= 10;
} What is the error in this code? String [] letters = {"F", "A", "V", "O", "R", "I", "T", "E"};
String what = scan.readLine();
int location = -1;
for (int i =0; i < letters.length; i++)
{
if ( what == letters[i])
{
location = i;
break;
}
}
System.out.println( location );
Why does this code sometimes produce an error?
int flag = 0;
for (int i = 0; i < d.length; i ++)
{
if (d[i] == value)
flag = 1;
}
if (flag == 1)
System.out.println("Value found at "+ i);
else
System.out.println("Value not found");
Which produce an ArrayIndexOutOfBounds error for int[ ] d = { 1,2,4,5,8}