CS 70

Homework 1: Written Questions

This assignment includes written questions, and you answer them with your partner. Work through them together, in the same way you pair on the code—do not split them up between you.

Either of you can type the answers in. Whoever saves last is what we see, the page says who saved it and when, and every earlier version is kept, so nobody can lose the other's words by editing over them.

  • RHS Cow speaking

    You don't need to finish answering these questions before you start the next part.

  • LHS Cow speaking

    Dive into the coding part with your partner in lab and come back to these questions later!

Question 1 – GitHub and the Command Line

1 point

Question 1.1

Let's say that you are starting up a new session, working on the CS 70 server to finish a coding assignment using your account. In your previous pair-programming session, you were logged into the server using your partner's account (and the time before that you checked out the code in your own account and worked on it together).

What do you need to do once you've logged in and changed into your repository directory?

2 points

Question 1.2

Imagine that you have a friend who is currently in CS 5 Gold.

How would you explain what version control is, and why it is important to them?

2 points

Question 1.3

Explain the difference between Git and GitHub to your imaginary friend.

2 points

Question 1.4

Explain the difference between cloning and pulling to them.

Question 2 – Scenarios

Based on the syllabus and the in-class discussion, find the best classification for each of the following scenarios

2 points

Question 2.1

Students A and B are paired. Unfortunately, A has two projects and a paper due this week. Finding it hard to schedule time to meet, the pair agrees that it's easier to divide the work: A will code the first half of the assignment, and then B will finish the remaining parts. They agree both will read the submitted code afterwards to make sure they both understand the whole assignment.

2 points

Question 2.2

Students A and B are paired. A CS 70 homework assignment asks for an implementation of Red-Black Trees. That data structure seemed to make sense in class, but afterwards A realizes that some parts still aren't clear. Student A sits down with classmate C. Comparing their class notes, together A and C realize they're both confused about the same point; they ask for clarification publicly, on the Key Points page for that lesson.

Question 3 – Testing

Suppose you were asked to test a function called absFloor. The function takes a double as input and returns a double. It is supposed to return the absolute value of the given value, rounded down to the nearest whole number.

Here is a correct implementation of this function:

double absFloor(double x) {
    double abs;
    if (x < 0) {
        abs = -x;
    } else {
        abs = x;
    }
    return floor(abs);
}

Give three different incorrect implementations, and, for each one, a test (input and expected output) that the incorrect implementation would fail.

2 points

Question 3.1

Incorrect implementation:

double absFloor(double x) {
}

Give a test that this implementation would fail.

Input:

absFloor(
);

Correct output (i.e., the output an implementation that isn't buggy would produce for this input):

2 points

Question 3.2

Incorrect implementation:

double absFloor(double x) {
}

Give a test that this implementation would fail.

Input:

absFloor(
);

Correct output (i.e., the output an implementation that isn't buggy would produce for this input):

2 points

Question 3.3

Incorrect implementation:

double absFloor(double x) {
}

Give a test that this implementation would fail.

Input:

absFloor(
);

Correct output (i.e., the output an implementation that isn't buggy would produce for this input):

To Complete This Part of the Assignment…

You'll know you're done with this part of the assignment when you've done all of the following:

(When logged in, completion status appears here.)