AP SEARCH AND SORT REVIEW Mr Crone Array

  • Slides: 34
Download presentation
AP SEARCH AND SORT REVIEW Mr. Crone

AP SEARCH AND SORT REVIEW Mr. Crone

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry.

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry. add(10); What does arry. get(3) return?

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry.

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry. add(10); // 0 1 2 3 What does arry. get(3) return? // Returns 10

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry.

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry. add(10); What does arry. index. Of(7) return?

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry.

Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry. add(10); // 0 1 2 3 What does arry. index. Of(7) return? // Returns 2

What does the following code print? Array. List<Integer> arry = new Array. List<Integer>(); arry.

What does the following code print? Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry. add(10); arry. remove(2); System. out. println(arry);

What does the following code print? Array. List<Integer> arry = new Array. List<Integer>(); arry.

What does the following code print? Array. List<Integer> arry = new Array. List<Integer>(); arry. add(4); arry. add(5); arry. add(7); arry. add(10); arry. remove(2); System. out. println(arry); // Prints [4, 5, 10]

The linear search method is coded below. What should be placed in the <missing

The linear search method is coded below. What should be placed in the <missing statement> line. public static int linear. Search(int[] arry, int target){ for(int i = 0; i < arry. length; i ++){ if(arry[i] == target) <missing statement> } return -1; }

The linear search method is coded below. What should be placed in the <missing

The linear search method is coded below. What should be placed in the <missing statement> line. public static int linear. Search(int[] arry, int target){ for(int i = 0; i < arry. length; i ++){ if(arry[i] == target) return i; } return -1; }

The sequential search method is coded below. What relational operator should be placed in

The sequential search method is coded below. What relational operator should be placed in the while loop condition to ensure that every element is checked? public static int linear. Search(int[] arry, int target){ int c = 0; while (c <missing operater> arry. length-1){ if(arry[ c] == target) return c; <missing Line> } return -1; }

The sequential search method is coded below. What relational operator should be placed in

The sequential search method is coded below. What relational operator should be placed in the while loop condition to ensure that every element is checked? public static int linear. Search(int[] arry, int target){ int c = 0; while (c <=arry. length-1){ if(arry[ c] == target) return c; <missing Line> } return -1; }

The sequential search method is coded below. What code can replace the <missing Line>

The sequential search method is coded below. What code can replace the <missing Line> to ensure that the method works correctly? public static int linear. Search(int[] arry, int target){ int c = 0; while (c <=arry. length-1){ if(arry[ c] == target) return c; <missing Line> } return -1; }

The sequential search method is coded below. What code can replace the <missing Line>

The sequential search method is coded below. What code can replace the <missing Line> to ensure that the method works correctly? public static int linear. Search(int[] arry, int target){ int c = 0; while (c <=arry. length-1){ if(arry[ c] == target) return c; c++ } return -1; }

Which search algorithm will be most efficient on the following array of numbers when

Which search algorithm will be most efficient on the following array of numbers when looking for the target value of 3? [2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 9, 10, 11, 12, 13, 13]

Which search algorithm will be most efficient on the following array of numbers when

Which search algorithm will be most efficient on the following array of numbers when looking for the target value of 3? [2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 9, 10, 11, 12, 13, 13] Sequential Search

The numbers below are sorted using the bubble sort. What is the next step

The numbers below are sorted using the bubble sort. What is the next step in the bubble sort algorithm? 2 2 5 1 1 3 7 1 5 1 3 7 1 1 5 3 7 …. .

The numbers below are sorted using the bubble sort. What is the next step

The numbers below are sorted using the bubble sort. What is the next step in the bubble sort algorithm? 2 2 5 1 1 1 1 5 3 3 5 7 7 // Answer

Is the code below an example of declaration or initialization? int num;

Is the code below an example of declaration or initialization? int num;

Is the code below an example of declaration or initialization? int num; Declaration

Is the code below an example of declaration or initialization? int num; Declaration

How many bits are in a byte?

How many bits are in a byte?

How many bits are in a byte? 8

How many bits are in a byte? 8

What is the concatenation operator?

What is the concatenation operator?

What is the concatenation operator? \ Answer +

What is the concatenation operator? \ Answer +

What does the following code print? System. out. println(“ 1” + new Integer(2) +

What does the following code print? System. out. println(“ 1” + new Integer(2) + 3);

What does the following code print? System. out. println(“ 1” + new Integer(2) +

What does the following code print? System. out. println(“ 1” + new Integer(2) + 3); // 123

What does the following code print? System. out. println(“Nums ” + 7+ 3);

What does the following code print? System. out. println(“Nums ” + 7+ 3);

What does the following code print? System. out. println(“Nums ” + 7+ 3); Nums

What does the following code print? System. out. println(“Nums ” + 7+ 3); Nums 73

Which of the following is not a method of java. util. Array. List? A.

Which of the following is not a method of java. util. Array. List? A. B. C. D. E. add(Object x); remove(Object x); insert(int i, Object x); contains(Object x); set(int i, Object x)

Which of the following is not a method of java. util. Array. List? A.

Which of the following is not a method of java. util. Array. List? A. B. C. D. E. add(Object x); remove(Object x); insert(int i, Object x); // Not a method contains(Object x); set(int i, Object x)

What will the following code print? int[][] arry = new int[3][4]; System. out. println(arry.

What will the following code print? int[][] arry = new int[3][4]; System. out. println(arry. length);

What will the following code print? int[][] arry = new int[3][4]; System. out. println(arry.

What will the following code print? int[][] arry = new int[3][4]; System. out. println(arry. length); // 3

What will the following code print? int n = 2005; for (int i =

What will the following code print? int n = 2005; for (int i = 0; i < 50; i++) n = (n + 3) / 2; System. out. println(n);

What will the following code print? int n = 2005; for (int i =

What will the following code print? int n = 2005; for (int i = 0; i < 50; i++) n = (n + 3) / 2; System. out. println(n); // 3