EECS2030 Test 5G


Programming question

Implement the Test5G class.


Other questions

Consider the following method:
/**
 * Checks if the length of the given string is even.
 * A length of zero is considered even.
 * 
 * @param s a string
 * @return true if s.length() is an even number
 */
public static boolean isEven(String s) {
  boolean result = false;
  if (s.isEmpty()) {
    result = true;
  }
  else if (s.length() == 1) {
    result = false;
  }
  else {
    result = isEven(s.substring(2));
  }
  return result;
}
Question 1

Prove the above method correct.



Question 2

Prove that the above method terminates.



Question 3

Explain the role of the model, the view, and the controller in the model-view-controller design pattern.



Question 4

Consider the following recurrence relation:

T(n) = 2T(n / 2) + n

In plain English, state the meaning of the recurrence relation.



Question 5

Prove that n log(n) + 100n + 5 is an element of O(n log(n))



Question 6

Provide the Javadoc comments needed to reproduce the API for the two methods in the programming question. You may omit the part of the comments that describe the examples and preconditions (i.e., document the parameters, the return value (if any), and the first sentence of the method description).