--- A B C D E ---- A B C D E
--- A B C D E ---- A B C D E
V = {A,B,C,D,E} E = {(A,C),(A,D),(A,E) (B,E),(C,A),(C,B), (C,D),(D,C),(E,D) }
E C B C B C E D D F B A B C C D E B B C A A C A B C E A F A C F C C D D
A B B A A B B A C D E C D E
A - B - D - C - E - C - C -
A A A A A B B B B B C C C C C D D D D D
(A) Anfang (A,B) (A,C) (A,D) (A,E) (A,C,D) (A,C,D,E) (A,C,D,E,B,A)
a. A y B b. C y A c. A d. B y C e. C
Halle A) B) C) D) E) Halle A) B) C) D) E)
A B C D E F G A B C D E F G
e a b c e e a b c a a b c e b b c e a c c e a b (ii)
TRACK & A-A-A-A B-B-B-B C-C-C-C D-D-D-D
21864 C D A B B A B B C D C C B
Clicker Question A. B. C. D. E
A B C D E Terminkalender 2013
"A" "B" "C" "D" "E" "F" "G"
These problems are similar to those you will see on the AP CS A exam.
7-10-1: Which of the following statements is a valid conclusion. Assume that variable b is an array of k integers and that the following is true: b[0] != b[i] for all i from 1 to k-1
7-10-2: Consider the following code segment. Which of the following statements best describes the condition when it returns true? boolean temp = false; for (int i = 0; i < a.length; i++) { temp = (a[i] == val); } return temp; You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-2.
7-10-3: Consider the following data field and method findLongest. Method findLongest is intended to find the longest consecutive block of the value target occurring in the array nums; however, findLongest does not work as intended. For example given the code below the call findLongest(10) should return 3, the length of the longest consecutive block of 10s. Which of the following best describes the value actually returned by a call to findLongest? private int[] nums = {7, 10, 10, 15, 15, 15, 15, 10, 10, 10, 15, 10, 10}; public int findLongest(int target) { int lenCount = 0; // length of current consecutive numbers int maxLen = 0; // max length of consecutive numbers for (int k = 0; k < nums.length; k++) { if (nums[k] == target) { lenCount++; } else if (lenCount > maxLen) { maxLen = lenCount; } } if (lenCount > maxLen) { maxLen = lenCount; } return maxLen; } You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-3. Can you fix the code in the Java Visualizer so that it works as intended?
7-10-4: Consider the following data field and method. Which of the following best describes the contents of myStuff in terms of m and n after the following statement has been executed? private int[] myStuff; //precondition: myStuff contains // integers in no particular order public int mystery(int num) { for (int k = myStuff.length - 1; k >= 0; k--) { if (myStuff[k] < num) { return k; } } return -1; } int m = mystery(n) You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-4.
7-10-5: Consider the following field arr and method checkArray. Which of the following best describes what checkArray returns? private int[] arr; // precondition: arr.length != 0 public int checkArray() { int loc = arr.length / 2; for (int k = 0; k < arr.length; k++) { if (arr[k] > arr[loc]) { loc = k; } } return loc; } You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-5.
7-10-6: Given the following field and method declaration, what is the value in a[1] when m1(a) is run? int[] a = {7, 3, -1}; public static int m1(int[] a) { a[1]--; return (a[1] * 2); } You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-6.
7-10-7: Consider the following code. What is the maximum amount of times that HELLO could possibly be printed? for (int i = 1; i < k; i++) { if (arr[i] < someValue) { System.out.print("HELLO") } } You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-7.
7-10-8: Consider the following method changeArray. An array is created that contains {2, 8, 10, 9, 6} and is passed to changeArray. What are the contents of the array after the changeArray method executes? public static void changeArray(int[] data) { for (int k = data.length - 1; k > 0; k--) data[k - 1] = data[k] + data[k - 1]; } You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-8.
7-10-9: Assume that arr1={1, 5, 3, -8, 6} and arr2={-2, -1, -5, 3, -4} what will the contents of arr1 be after copyArray finishes executing? public static void copyArray(int[] arr1, int[] arr2) { for (int i = arr1.length / 2; i < arr1.length; i++) { arr1[i] = arr2[i]; } } You can step through the code above with the Java Visualizer by clicking the following link Prob-7-10-9.
7-10-10: Given the following code segment, which of the following will cause an infinite loop? Assume that temp is an int variable initialized to be greater than zero and that a is an array of ints. for ( int k = 0; k < a.length; k++ ) { while ( a[ k ] < temp ) { a[ k ] *= 2; } } You can step through the code above using the Java Visualizer by clicking on the following link Prob-7-10-10. Can you fix the code so that it won’t result in an infinite loop? |