CS35: Data Structures and Algorithms

Week 01 Lab Notes

Welcome

Welcome to CS35 Lab. This week is a little unusual in that we haven't really learned enough to start a typical CS35 lab. A typical lab session usually consists of a few small exercises or demos, followed by a short introduction to the week's lab. Afterwards, you will have time to read the lab in detail and begin working on your solutions. While we do have a short lab exercise for you this week, the focus of this lab session is configuring your CS and Swarthmore Github accounts so you can retrieve and submit code with partners, instructors, and graders.

Initial Setup

If this is your first CS course, note that the CS machines are on a different network than other campus machines hosted by ITS. Your username will be the same as your ITS login, but you will have a different password. We provide a random password for new accounts, but once you login, you can open a terminal and change it to something easier by typing the command passwd and following the prompts. If you forget your password later, you can reset it online at password.cs.swarthmore.edu.

Once you are logged in, open a browser and a terminal. For additional help on understanding the CS environment, CS students are hosting two Using Unix sessions

Additionally, we have a number of resources online for Unix help.

You are free to use any editor you want. I will tend to use vim.

Using Git

Git is a popular piece of open-source software which is installed on the Swarthmore CS computers. Git is a version control system---it can be used to manage changes and updates in software and facilitate collaborative programming across large teams of developers. We'll be using git to manage assignment distribution and submission. When you start an assignment, you'll execute a git command to grab some starting files. Similarly, when you want to submit an assignment, you'll execute a couple of git commands. Later on in the course, you'll be using git to facilitate paired lab assignments.

Git is a large piece of software, and there is a lot to learn with git. Fortunately, it is easy to get up and running on git with just a small number of commands.

  1. If you have never done so before, create and enter your SSH key in github by following the instructions here.
  2. Create a cs35 folder, change to that directory and create a directory for lab assignments
    cd ~/
    mkdir cs35
    cd cs35
    mkdir labs
    
  3. We recommend that you read the "Commands for using a git repo" that lists the commands that you will need to submit your lab assignments. In particular, you should understand how to use "git add", "git commit" and "git push".

This might seem like a lengthy sequence of commands to remember, but don't worry! We'll go over this in lab next week, and the commands will be the same for each assignment during the semester.

To recap, the git commit cycle is git add, git commit, git push. Don't forget to git push when you have completed an assignment.

Getting starter code
We are going to grab sample code and lab assignments to place in these folders using git.
  1. Clone the git repo for examples we will cover together in this lab by executing this command from your cs35 directory:
    git clone git@github.swarthmore.edu:CS35-F17/examples-<user>.git  ./examples
    
    where <user> is your username.
  2. Clone the git repo for lab00 by executing these commands:
    cd ~/cs35/labs
    git clone git@github.swarthmore.edu:CS35-F17/lab00-<user>.git  ./lab00
    
    where <user> is your username.
  3. At this point, you should have the lab starter code and be ready to program the lab.

Intro to C++

Instead of diving right into the lab assignment, let's look at the C++ code you for from git together. We will follow the week-01 README.md to explore the code. You may (have already) explore(d) some of this in class.

Lab 00

Head back to Lab 00 and read the second half of the writeup. You are asked to individually write two small sample programs and submit them via git by Sunday night. If you have questions, feel free to ask me or a ninja for assistance. The first few labs will be individual assignments as you get practice with C++. Later in the semester, we will allow partnered labs. Introduce yourself to your neighbors and perhaps think about who you might like to work with in the future. But for this lab, you should work on your code individually and only consult with Instructors, Ninjas, Piazza, and approved web resources.

Extras

We may not have time to cover these topics in lab.

You are encouraged to configure your git profile on github. Please at least add your preferred name and email.

Practice breaking some of the example programs in controlled ways and see what error messages are generated. Recognizing common compiler error messages now will help you debug programs later as they become bigger and more complex.

Test the robustness of cin in C++. By giving invalid input. While handling all forms of user input correctly will not be a focus of this course, it is handy to know how to terminate a program that hangs. Try Ctrl-C if things get stuck.