Name ____________________ Community Standard Acknowledgment ___________________Note that this exam has 10 pages: Check!
Watch your time! You only have 75 minutes. You should not spend too long on any one problem on your first pass.
If you run out of space to do a problem, continue it on the back of the previous page!
Problem | Value | Points Earned |
Prob 1 | 5 | |
Prob 2 | 6 | |
Prob 3 | 6 | |
Prob 4 | 10 | |
Prob 5 | 10 | |
Prob 6 | 6 | |
Prob 7 | 12 | |
Prob 8 | 10 | |
Prob 9 | 7 | |
total | 72 |
Closed Book
You may refer to reference sheets that have been distributed that are extracted from the Java API. These should provide reminders of some of the standard classes and methods that we have used.
countTriple("abcXXXabc") returns 1 countTriple("xxxabyyyycd") returns 3 countTriple("a") returns 0 countTriple("") returns 0 countTriple("XXXXXabc") returns 3Your method has been started for you below with its header.
For example, given an array
{"one", "too", "not", "too", "three", "not"},
mode should return 1, the index of "too"".
(Both "too" and "not" occur twice, but
"too" came first.)
{"A", "A", "A", "A", "B", "A", "C", "C", "C"}?
Start with the header shown below;
sameEnds({5, 6, 45, 99, 13, 5, 6}, 1) returns false sameEnds({5, 6, 45, 99, 13, 5, 6}, 2) returns true sameEnds({5, 6, 45, 99, 13, 5, 6}, 3) returns false sameEnds({1, 2, 5, 2, 1}, 0) returns true sameEnds({1, 1, 1}, 3) returns true sameEnds({}, 0) returns trueYour method has been started for you below with its header
for (int k = 0; k < n; k++) { doSomethingBig(n); // some task requiring #### O(N2) #### time }
Complexity = O(______)
public int winsACC, lossesACC, winsNC, lossesNC; public String schoolName;where the ints give you the number off wins and losses in the ACC and Non-Conference. You plan to sort an array of ACC schools to get the ACC tournament seeding. Remember that the lower the seed, the better the team. On sorting, the best team should end up first in the array.
Write a complete comparator to help you sort an array of ACCSchools. Name it ACCComparator and have it implement Comparator. Remember, it only needs to include a single method.
(If you don't know how to do this, but do know how to make the class ACCSchool comparable, then you may choose that option, but you forfeit 2 points. In that case, write the method needed to make ACCSchool implement Comparable.)
Here are the rules to compare two schools (not the official ones). Base it on:
isPalindrome(121) returns true; isPalindrome(12321) returns true; isPalindrome(11) returns true; isPalindrome(0) returns true; isPalindrome(1232) returns false; isPalindrome(2321) returns false;To earn full credit for this problem you may not use any methods that you do not write and may not use any of the classes and methods in the Java API. You may use an array. You can earn two points of extra credit if you do it without using an array.
Your method has been started for you below with its header