Assume the following list of integers:
18, 45, 33, 65, 76, 32, 96, 12, 46, 68
After three iterations, the list looks like this:
12, 18, 32, 65, 76, 33, 96, 45, 46, 68
What type of sort was used? Consider the following code segment.
int list[] = {1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50};
for (int d = 1; d < list.length; k++)
list[d] = list[d] / list[1];
for (int d = 0; d < list.length; k++)
System.out.print(list[d] + " ");
What will be output when the program segment executes? Consider the array declaration that follows.
int[] a = {1, 3, 5, 6, 7, 8, 9, 11, 13, 14, 15};
How many comparisons would it take if you were to search the array for 3 using a binary search? Consider the following code segment:
String words [] = {"avocado", "buffet", "carrot", "center", "meaning", "couch", "furniture", "sleep", "peccadillo", "friendly", "potatoes"};
int x = 0;
for(int i = 0; i < words.length; i++)
{
if (words[i].substring(0,3).indexOf('o') >= 0)
x++;
}
System.out.println(x);
What is the output?