Midterm Review
> Click or hit Control-Enter to run the code above
Checkpoint 0
You’ve come a long way in four weeks.
Midterm Goal
I want to ensure that you are ready to go on and succeed in CS 125.
Midterm Format
-
12 multiple-choice questions, mostly on code reading
-
3 programming questions:
-
one using arrays,
-
one using multi-dimensional arrays,
-
and one using strings.
-
-
One programming question will be drawn directly from the HW125 practice problems. So use those to prepare.
Warm Up: Array Sum
Sum all values in a one-dimensional array of int values.
> Click or hit Control-Enter to run the code above
String Equality
Write a function called areEquals that takes two String arguments and returns
true if the two strings are equal (that is, they contain the same characters)
and false otherwise.
Note that either first or second may be null.
If either are null you should return false, including if both are null.
What’s an algorithm?
-
Eliminate the
nullcases -
Go through each
Stringcharacter by character… -
…or just read the docs.
> Click or hit Control-Enter to run the code above
String Rotate Left
Write a function called rotateLeft that takes a String as its first argument and
a positive int as its second argument and rotates the String left by the given
number of characters.
What’s an algorithm?
-
Create a new character array of the same size as the input
-
Go through the passed string character by character
-
Compute the new position for that character
-
Copy the character into position in the new character array
> Click or hit Control-Enter to run the code above
Announcements
-
Next week we will hold our first midterm exam: a one-hour quiz worth 2% of your grade that cannot be dropped
-
Monday we will begin discussing objects!
-
Office hours for MP0 continue—good luck finishing up!
-
The second MP checkpoint—MP1—will be released this weekend to ensure that the Blue Team can begin work on it as soon as they are done with MP0.