Download presentation
Presentation is loading. Please wait.
1
AP Search and Sort Review
Mr. Crone
2
ArrayList<Integer> arry = new ArrayList<Integer>(); arry
ArrayList<Integer> arry = new ArrayList<Integer>(); arry.add(4); arry.add(5); arry.add(7); arry.add(10); What does arry.get(3) return?
3
ArrayList<Integer> arry = new ArrayList<Integer>(); arry
ArrayList<Integer> arry = new ArrayList<Integer>(); arry.add(4); arry.add(5); arry.add(7); arry.add(10); // What does arry.get(3) return? // Returns 10
4
ArrayList<Integer> arry = new ArrayList<Integer>(); arry
ArrayList<Integer> arry = new ArrayList<Integer>(); arry.add(4); arry.add(5); arry.add(7); arry.add(10); What does arry.indexOf(7) return?
5
ArrayList<Integer> arry = new ArrayList<Integer>(); arry
ArrayList<Integer> arry = new ArrayList<Integer>(); arry.add(4); arry.add(5); arry.add(7); arry.add(10); // What does arry.indexOf(7) return? // Returns 2
6
What does the following code print
What does the following code print? ArrayList<Integer> arry = new ArrayList<Integer>(); arry.add(4); arry.add(5); arry.add(7); arry.add(10); arry.remove(2); System.out.println(arry);
7
What does the following code print
What does the following code print? ArrayList<Integer> arry = new ArrayList<Integer>(); arry.add(4); arry.add(5); arry.add(7); arry.add(10); arry.remove(2); System.out.println(arry); // Prints [4, 5, 10]
8
The linear search method is coded below
The linear search method is coded below. What should be placed in the <missing statement> line. public static int linearSearch(int[] arry, int target){ for(int i = 0; i < arry.length; i ++){ if(arry[i] == target) <missing statement> } return -1;
9
The linear search method is coded below
The linear search method is coded below. What should be placed in the <missing statement> line. public static int linearSearch(int[] arry, int target){ for(int i = 0; i < arry.length; i ++){ if(arry[i] == target) return i; } return -1;
10
The sequential search method is coded below
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 linearSearch(int[] arry, int target){ int c = 0; while (c <missing operater> arry.length-1){ if(arry[ c] == target) return c; <missing Line> } return -1;
11
The sequential search method is coded below
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 linearSearch(int[] arry, int target){ int c = 0; while (c <=arry.length-1){ if(arry[ c] == target) return c; <missing Line> } return -1;
12
The sequential search method is coded below
The sequential search method is coded below. What code can replace the <missing Line> to ensure that the method works correctly? public static int linearSearch(int[] arry, int target){ int c = 0; while (c <=arry.length-1){ if(arry[ c] == target) return c; <missing Line> } return -1;
13
The sequential search method is coded below
The sequential search method is coded below. What code can replace the <missing Line> to ensure that the method works correctly? public static int linearSearch(int[] arry, int target){ int c = 0; while (c <=arry.length-1){ if(arry[ c] == target) return c; c++ } return -1;
14
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, 11, 12, 13, 13, 13]
15
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, 11, 12, 13, 13, 13] Sequential Search
16
The numbers below are sorted using the bubble sort
The numbers below are sorted using the bubble sort. What is the next step in the bubble sort algorithm? …..
17
The numbers below are sorted using the bubble sort
The numbers below are sorted using the bubble sort. What is the next step in the bubble sort algorithm? // Answer
18
Is the code below an example of declaration or initialization? int num;
19
Is the code below an example of declaration or initialization
Is the code below an example of declaration or initialization? int num; Declaration
20
How many bits are in a byte?
21
How many bits are in a byte? 8
22
What is the concatenation operator?
23
What is the concatenation operator? \\ Answer +
24
What does the following code print. System. out
What does the following code print? System.out.println(“1” + new Integer(2) + 3);
25
What does the following code print. System. out
What does the following code print? System.out.println(“1” + new Integer(2) + 3); // 123
26
What does the following code print. System. out
What does the following code print? System.out.println(“Nums ” );
27
What does the following code print. System. out
What does the following code print? System.out.println(“Nums ” ); Nums 73
28
Which of the following is not a method of java.util.ArrayList?
add(Object x); remove(Object x); insert(int i, Object x); contains(Object x); set(int i, Object x)
29
Which of the following is not a method of java.util.ArrayList?
add(Object x); remove(Object x); insert(int i, Object x); // Not a method contains(Object x); set(int i, Object x)
30
What will the following code print
What will the following code print? int[][] arry = new int[3][4]; System.out.println(arry.length);
31
What will the following code print
What will the following code print? int[][] arry = new int[3][4]; System.out.println(arry.length); // 3
32
What will the following code print
What will the following code print? int n = 2005; for (int i = 0; i < 50; i++) n = (n + 3) / 2; System.out.println(n);
33
What will the following code print
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
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.