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
null
cases -
Go through each
String
character 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
> Click or hit Control-Enter to run the code above
String Rotation Master Class
Let’s look at some ways to do HW18.
-
Note that all of these passed our test suite.
-
But that doesn’t mean that they are all correct.
-
I’m not going to post these as part of the slide deck to avoid disseminating potentially bad solutions
-
Is this your code? Probably not—it’s from last semester.
> Click or hit Control-Enter to run the code above
> Click or hit Control-Enter to run the code above
> Click or hit Control-Enter to run the code above
Tic-Tac-Toe Master Class
Let’s look at some ways to do HW22.
-
Note that all of these passed our test suite.
-
But that doesn’t mean that they are all correct.
-
I’m not going to post these as part of the slide deck to avoid disseminating potentially bad solutions
-
Is this your code? Maybe. Maybe not.
> Click or hit Control-Enter to run the code above
> Click or hit Control-Enter to run the code above
> 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
-
No labs as scheduled next week. Instead, we’ll hold office hours during the same times in Siebel 0403. Come to get some help preparing for the midterm.
-
Today I’ll be doing one James Scholar interview session, here, now. If you want to interview me for your project this is your chance.
-
Monday we will begin discussing objects!
-
Office hours for MP1 continue—please get started, since it will help you prepare for the midterm exam next week