CS 21: The Imperative Paradigm: Unix and C

Spring Semester 2005
Swarthmore College

Section 1
TR 2:40-3:55, Sci. Center 240

Professor: Tia Newhall

Office hours:
Office: 249 Science Center


Course Description, Text
Class Schedule Topics, Readings, Assignments, Due Dates
How to Succeed in CS21
About the CS Lab
Academic Integrity
Links to Unix and C help

Course Description

This course introduces students to fundamental ideas in computer science using the C programming language and the Unix operating system environment. Class periods will consist of a combination of lectures and hands-on interaction at the computer. Topics to be covered include an overview of the Unix operating system, elementary Unix tools, modular software design, recursion and iteration, sorting and searching, abstract data types and their representations, lists, trees, informal analysis of algorithms, and a thorough introduction to C programming, including control structures, functions and procedural abstraction, libraries and modules, arrays, pointers, string manipulation, file processing, and records.

We will be paying particular attention to developing a good programming style. Your homework grade will be strongly influenced by the legibility of your code, so it is very important to develop a clear, logical, aesthetically pleasing programming style, making judicious use (but not overuse) of comments, whitespace, well-chosen variable names, and a consistent indentation style. There will be numerous programming assignments illustrating the concepts covered in class.


The required textbook for the course is The Art and Science of C: An Introduction to Computer Science, by Eric S. Roberts

There are also many C language references in the CS lab that you may use while you work in the lab (you may not remove them from the lab).

How to Succeed in CS21


20% Exam 1: Thursday, Feb. 24 (in class exam)
20% Exam 2: Thursday, April 7, 7-9pm in SCI 101
25% Exam 3: 9:00-12:00 May 14th in SCI 199
30% Homework
5% Class Participation and Quizzes


Homework will generally be assigned on Tuesdays, and will be due the following Sunday by 11:30pm. Typically, each assignment will consist of several separate programs. Only one of these programs will be graded (you will not know which one in advance). If you do not submit the program that is selected for grading, you will receive a zero for the assignment. Some homework assignments may have optional problems that you can complete for extra credit points.

Your homework assignments will be turned in electronically, using a special cs21handin program (to be explained in class). Late homework is not accepted. However, if you miss a deadline, you are strongly encouraged to complete the assignment anyway, since this really is the only effective way to learn the material.

Because many students feel they learn more through collaboration, you may work jointly with one other person on some designated assignments (although you may work alone if you wish). No more than two people should work together. If you work with someone else, you must submit a single, joint assignment with both names clearly indicated at the top of your program file(s). I will let you know which assignments you are allowed to collaborate on.

Homework assignments will be given a numerical grade according to the criteria shown below. Note that a program that works 100% correctly gets a 3. In order to get an 4, your program also needs to be clearly organized and well-documented (but this doesn't mean over-documented!). The numerical grades will be scaled in some way so that the difference between a 4 and a 3 is more like the difference between an A and a B grade.

4 correct, logically designed, well-documented, efficient
3 correct, but has stylistic problems
2 partially correct
1 does not compile or execute

If there are known problems with your code, you should describe these problems in a comment at the top of your program file.

About the CS Lab

The CS Lab (room 240) and the overflow lab (room 238) are open 24 hours a day for CS students to work on their course assignments. When the CS Lab is in use by a class, you should work in the overflow lab.

We will distribute MicroProx tags to attach to your student ID sometime in the first or second week of classes. These will allow you entry to the CS Lab and entry into the Science Center after building hours. You should use the door between Martin and Cornell to get into the building after midnight.

Academic Integrity

The College's Judiciary Committee (CJC) handles plagiarism offenses. The penalties for plagiarism are quite severe: usually the first offense leads to failure in the course, but it may additionally result in suspension. The following constitutes plagiarism on CS programming assignments:

Under no circumstances may you hand in work done with (or by) someone else under your own name. Your code should never be shared with anyone; you may not examine or use code belonging to someone else, nor may you let anyone else look at or make a copy of your code. This includes sharing solutions after the due date of the assignment. Failure to abide by these rules constitutes academic dishonesty and will lead to a hearing of the College Judiciary Committee.

The exception is that you may use code that the instructors have distributed in class and code from the book (you should cite this code as coming from the instructor or from the book). Also, if you work with a partner, then you and your partner may share code for the particular assignment on which you work jointly (again, both your names must appear in the comment at the top of the file). Additionally, CS21 clinicians are allowed to help you with your code.

Discussing ideas and approaches to problems with others on a general level is fine (in fact, we encourage you to discuss general strategies with each other), but you should never read anyone else's code or let anyone else read your code. If you are in doubt about some help that you received, then credit the person(s) from whom you got help and discuss the situation with your instructor.

For some examples of what we consider "okay" and "not okay" collaboration, look at the scenarios below.

Homework Scenarios

These are OK:

These are definitely NOT OK:


Each week we will have CS21 clinics in the main CS Lab at the following times:
  • Thursday 7-9pm, clinician Alex Benn
  • Saturday 1-4pm, clinician Megan Schuster
  • Sunday 2-4 pm, clinician E.B. Fouts
During clinic hours, the clinician is available to help with your weekly programming assignments.


Answers to Review Questions from homework assignments

1 1/17 Introduction to C Programming 1, 2 Using Unix I:
Tues, Jan 18, 4-5pm
Tues, Jan 18, 7:30-8:30pm (repeat session)

Clinics start Thursday night

2 1/24 Problem Solving 3, 4 Add/Drop ends 1/28

Using UnixII
Tues, Jan 25, 4-5pm
Tues, Jan 25, 7:30-8:30pm (repeat session)

3 1/31 Functions and Debugging 5, 6 C Code Style Guide (read "Function Comments" and "Line Length" parts) Tues hw4
4 2/7 Libraries and Graphics
Libraries and Random Numbers
7, 8 - Tues
5 2/14 Arrays 11 - Tues
6 2/21 Arrays 11 Exam 1, Thursday in class
Exam 1 Topics
Tia's office hours this week: Tues 4-5pm, Wed 1-2pm
- hw7
7 2/28 Searching, Sorting, and Analysis of Algorithms 12, 17.3 - Tues
- - Spring Break - Spring Break - -
8 3/14 Pointers 13
- Tues
9 3/21 Pointers cont. - - Tues and Thurs hw9
10 3/28 Characters and Strings 9.2, 14
- Tues
11 4/4 Reading and writing files, makefiles 15
file I/O
Exam 2, Thursday evening
7-9pm in SCI 101

Exam 2 Topics
Tues hw11
12 4/11 Records

note: there are many ways to define structs in C. You should define them the way I do in class rather than the way the book does it.

16 - Tues & Thurs -
13 4/18 Linked Lists 17.2, handouts
Linked Lists
- Tues hw12
14 4/25 Binary Trees Binary Search Trees - Tues -
Finals - - - Exam 3, 9:00-12:00 am May 14th in SCI 199
Exam 3 Topics
Exam 3 Review Sessions: Wed May 11, 5:30-6:30 in the CS Lab (Tia)
- -

On-line References