This course teaches imperative programming and methods for ensuring the correctness of programs. It is intended for students with a basic understanding of programming (variables, expressions, loops, arrays, functions). Students will learn the process and concepts needed to go from high-level descriptions of algorithms to correct imperative implementations, with specific applications to basic data structures and algorithms. Much of the course will be conducted in a subset of C amenable to verification, with a transition to full C near the end.
This will be accomplished along three dimensions:
*Introduction to Computer Systems*), 15-210 (*Parallel and Sequential Data Structures and Algorithms*) and 15-214 (*Principles of Software System Construction*). Other prerequisites or restrictions may apply.
### Prerequisites

You must have gotten a 5 on the AP Computer Science A exam or passed 15-112 (*Fundamentals of Programming*) or equivalent. You may also get permission from an advisor if you performed very high on the CS Assessment on Blackboard.

It is**strongly** advised that you either have taken or take at the same time either 21-127 (*Concepts of Mathematics*) or 15-151 (*Mathematical Foundations of Computer Science*): historically, students who did not ended up with a course grade one letter grade lower than their peers who did, in average.
### Past Offerings

F'16
M'16
S'16
F'15
M'15
S'15
F'14
M'14
S'14
F'13
M'13
S'13
F'12
M'12
S'12
F'11
M'11
S'11
F'10

- The main skill you will get out of this course is the ability to write code that is correct by design and accounts for the needs of its application context. You will learn about deliberate programming as a way to write high quality code, about assessing the performance of a program, and about comparing solutions to satisfy deployment constraints.
- As we do so, you will learn and build an appreciation for fundamental concepts in Computer Science, such as abstraction, correctness, complexity, and modularity. This will also give you a vocabulary to communicate effectively and precisely with other computer scientists.
- Our vehicle for achieving these objectives will initially be C0, a safe variant of C, and later C itself. Using it, you will gain exposure to a number of data structures and algorithms that are used pervasively in computer science. C is the language of choice for system-level code, and both are representative of the popular imperative programming paradigm.

It is

It is our goal to make this course successful, stimulating and enjoyable. If at any time you feel that the course is not meeting your expectations or you want to provide feedback on how the course is progressing for you, please contact us. If you would like to provide anonymous comments, please use the feedback form on the course home page or slide a note under our doors. Comments of general interest will be answered on the course discussion board.

There is no textbook for this course. Lecture notes and other resources are provided through the Schedule tab of this page. We do not require students to read lecture notes before lecture, but those who are interested in reading ahead can certainly do so.

- From C0 to C: Basics tutorial
- C Language Libraries
- POSIX library standard — Unix standard library definitions including a library search functionality

Unix | Emacs |
---|---|

This is a **10 unit** course.
### Tasks and Percentages

### Evaluation Criteria

Your assignments and exams are evaluated on the basis of:
### Late Policy

*really* need an extension on a particular assignment, contact the instructors as soon as possible before the deadline. Please be aware that extensions are entirely discretionary and will be granted only in exceptional circumstances (e.g., due to severe illness or major personal/family emergencies, but not for competitions, club-related events or interviews). The instructors will most likely require confirmation from University Health Services or your academic advisor, as appropriate.
Nearly all situations that lead to asking for an extension to a homework can be avoided with proper planning — often just starting early. Here are some examples:
### Grade Appeals

We make mistakes too!

After each exam and homework assignment is graded, you will be able to access your score by clicking on the Grades tab of this page. We will make the utmost effort to be fair and consistent in our grading. Any TA is permitted to fix simple arithmetic errors (and, at their discretion, other blindingly obvious grading errors). For any other grading issues, you must request a regrade as follows:### Final Grades

This class is not curved.
What follows is a **rough guide** to how course grades will be established, not a precise formula — we will fine-tune cutoffs and other details as we see fit after the end of the course. This is meant to help you set expectations and take action if your trajectory in the class does not take you to the grade you are hoping for (see also the Grades tab on this page). So, here's a **rough**, *very rough* heuristics between final grades and total scores:

Precise grade cutoffs will not be discussed at any point during or after the semester. For students very close to grade boundaries, instructors may, at their discretion, consider participation in lecture and recitation and exam performance when assigning the final grade.### Academic Integrity

You are expected to comply with the University Policy on Academic Integrity and Plagiarism (see also The Word and Understanding Academic Integrity).
The university policies and procedures on academic integrity will be applied rigorously. All students are required to fill out a form as part of their first assignment indicating that they understand and accept this policy.
The value of your degree depends on the academic integrity of yourself and your peers in each of your classes. It is expected that, unless otherwise instructed, the work you submit as your own is your own work and not someone else’s work or a collaboration between yourself and other(s).
Please read the University Policy on Academic Integrity carefully to understand the penalties associated with academic dishonesty at Carnegie Mellon. In this class, cheating/copying/plagiarism means copying all or part of a program or homework solution from another student or unauthorized source such as the Internet, having someone else do a homework or take an exam for you, knowingly giving such information to another student, reusing answers or solutions from previous editions of the course, or giving or receiving unauthorized information during an examination. In general, each solution you submit (quiz, written assignment, programming assignment, midterm or final exam) must be your own work. In the event that you use information written by another person in your solution, you must cite the source of this information (and receive prior permission if unsure whether this is permitted). It is considered cheating to compare complete or partial answers, discuss details of solutions, or sit near another person who is taking the same course and try to complete the assignment together. It is also considered cheating for a repeating student to reuse one's solutions from a previous semester, or any instructor-provided sample solution. It is a violation of this policy to hand in work for other students.
Your course instructor reserves the right to determine an appropriate penalty based on the violation of academic dishonesty that occurs. Penalties are severe: a typical violation of the university policy results in the student failing this course, but may go all the way to expulsion from Carnegie Mellon University. If you have any questions about this policy and any work you are doing in the course, please feel free to contact the instructors for help.
We will be using the Moss system to detect software plagiarism.
It is not considered cheating to clarify vague points in assignments, lectures, lecture notes, or to give help or receive help in using the computer systems, compilers, debuggers, profilers, or other facilities, but you must refrain from looking at other students' code while you are getting or receiving help for these tools. It is not cheating to review graded assignments or exams with students in the same class as you, but it is considered unauthorized assistance to share these materials between different iterations of the course. Do not post code from this course publicly (e.g., to Bitbucket or GitHub).

**24 homework assignments: 45%**- 13 weekly
*written assignments*(due on Gradescope Mondays at 9pm — strict!) - 11 mostly weekly
*programming assignments*(due on Autolab Thursdays at 9pm — strict!)

- No joint homework unless explicitly instructed.

- 13 weekly
**2 midterm exams: 12.5% each**, in class, closed books, on and**Final exam: 25%**, 3 hours, closed books, on**Labs and quizzes: 5%**

Each lab is graded on a 0-3 point scale, assigned as follows:- 3 points for completing all exercises
- 2 points for completing sufficiently many exercises
- 1 point for completing some exercises but not quite enough to get a good practice
- 0 points for not completing any exercise, not showing up, or coming to the wrong section

*All you need is to earn the 5% grade for this portion of the course is to accumulate 50 points overall.*There are many more points than that for grabs, so no sweat if you do poorly in one quiz or miss a lab. Do the math: the course has- 13 graded labs
- a few quizzes (done during lecture and/or recitation)

**Correctness**: Your arguments should make sense, your proofs should be valid, and your program should work in the reference environment**Elegance**: Written material should be of the same quality as what a professional would write. No typos, no bad grammar, clarity is paramount. You are also expected to write code with good programming style. See these notes about what constitutes good style.

For a small subset of assignments, the course staff will review all final submissions by hand. If there are significant style issues, they may give a non-passing grade on style, accompanied by a “FIX STYLE” annotations in their notes. Students who are told to fix their style must address these issues and discuss their revisions with a TA**within 5 days**of the style grades being posted. Any TA or instructor can do style re-grading at any office hour; you do not have to go to the TA that assigned the grade.

- There are
**no late days for written assignments**, but written homework will be accepted up to 12 hours past the deadline for a 50% penalty. - Each student has
**3 late days for programming assignments**but you may use**at most one late day for each individual assignment**. This means that for exactly 3 programming deadlines you can turn in your assignment within 24 hours after the deadline. Autolab handles these late days automatically — you don't have to email the course staff, just turn in the assignment between 1 second late and 24 hours after the deadline.

*I have so many deadlines this week*: you know your deadlines ahead of time — plan accordingly.*It's a minute before the deadline and the network is down*: you always have multiple submissions — it's foolish to wait for the deadline for your*first*submission.*My computer crashed and I lost everything*: Use Dropbox or similar to do real-time backup — recover your files onto AFS and finish your homework from a cluster machine.*My fraternity/sorority/club has that big event that is taking all my time*: Schedule your extra-curricular activities around your classes, not vice versa.

After each exam and homework assignment is graded, you will be able to access your score by clicking on the Grades tab of this page. We will make the utmost effort to be fair and consistent in our grading. Any TA is permitted to fix simple arithmetic errors (and, at their discretion, other blindingly obvious grading errors). For any other grading issues, you must request a regrade as follows:

- Compose a properly typed letter explaining where and why you think there was a mistake in grading. Write
**at most 3 lines**for each response you are disputing. Make sure to specify which homework or exam this appeal is for.**Date and sign your letter by hand**. - Hand-deliver a signed
**hardcopy**of this letter to in . Slide it under her door if she is not in.**Verbal, email or handwritten requests will not be accepted.** - All regrade requests must be recieved within
**5 days**of the work being handed back on Gradescope or Autolab, which we will announce in a Piazza post

- A: above 90%
- B: 80-90%
- C: 70-80%
- D: 60-70%

Precise grade cutoffs will not be discussed at any point during or after the semester. For students very close to grade boundaries, instructors may, at their discretion, consider participation in lecture and recitation and exam performance when assigning the final grade.

**CaPS:**412-268-2922**Re:solve Crisis Network:**888-796-8226**If the situation is life threatening,**call the police:- On campus (CMU Police): 412-268-2323
- Off campus: 911

- develop contracts (preconditions, postconditions, assertions, and loop invariants) that establish the safety and correctness of imperative programs.
- develop and evaluate proofs of the safety and correctness of code with contracts.
- develop and evaluate informal termination arguments for programs with loops and recursion.
- evaluate claims of both asymptotic complexity and practical efficiency of programs by running tests on different problem sizes.
- define the concept of programs as data, and write programs that use the concept.
- defend the use of abstractions and interfaces in the presentation of algorithms and data structures.
- identify the difference between
*specification*and*implementation*. - compare different implementations of a given specification and different specifications that can be applied to a single implementation.
- explain data structure manipulations using data structure invariants.
- identify and evaluate the use of fundamental concepts in computer science as problem-solving tools:
- order (sorted or indexed data),
- asymptotic worst case, average case, and amortized analysis,
- randomness and (pseudo-)random number generation, and
- divide-and-conquer strategies.

- trace the operational behavior of small imperative programs.
- identify, describe, and effectively use basic features of C0 and C:
- integers as signed modular arithmetic,
- integers as fixed-length bit vectors,
- characters and strings,
- Boolean operations with short-circuiting evaluation,
- arrays,
- loops (
`while`and`for`), - pointers,
- structs,
- recursive and mutually recursive functions,
`void`pointers and casts between pointer types,- contracts (in C0), and
- casts between different numeric types (in C).

- translate between high-level algorithms and correct imperative code.
- translate between high-level loop invariants and data structure invariants and correct contracts.
- write code using external libraries when given a library interface.
- develop, test, rewrite, and refine code that meets a given specification or interface.
- develop and refine small interfaces.
- document code with comments and contracts.
- identify undefined and implementation-defined behaviors in C.
- write, compile, and test C programs in a Unix-based environment
using
`make`,`gcc`, and`valgrind`.

- define and describe big-O notation, both formally and informally.
- compare common complexity classes like
*O(1)*,*O(n)*,*O(n log(n))*,*O(n2)*, and*O(2n)*. - explain the structure of basic amortized analysis proofs that use potential functions.
- apply principles of asymptotic analysis and amortized analysis to new algorithms and data structures.
- recognize properties of simple self-adjusting data structures.
- recognize algorithms and data structures using divide-and-conquer.
- describe and employ a number of basic algorithms and data structures:
- integer algorithms,
- linear search,
- binary search,
- sub-quadratic complexity sorting (mergesort and quicksort),
- stacks and queues,
- pseudo-random number generators,
- hash tables,
- priority queues,
- balanced binary search trees,
- disjoint-set data structures (union/find), and
- simple graph algorithms.

2017 Iliano Cervesato |