Click on a class day to go to that particular lecture or recitation. Due
dates for homeworks are set in bold. The due date
of the next homework blinks.
Description
This course teaches imperative programming in a C-like language and
methods for ensuring the correctness of imperative programs. It is
intended for students who are familiar with elementary programming
concepts such as variables, expressions, loops, arrays, and
functions. Given these building blocks, students will learn the
process and techniques 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:
-
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 you do so, you will gain exposure to fundamental concepts in
Computer Science — as opposed to programming — 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 them, 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 applications, and both are representative of the popular
imperative programming paradigm.
After completing 15-122, you will be able to
take
15-213
(
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 Canvas.
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 do so ended up learning less, spending
considerably more time on the course and earning one letter grade
lower than their peers who did, on average.
Past Offerings
How to do Well in this Course
Our goals are for you to succeed in this course and to teach you
skills and concepts that will contribute to your success in life. To
this end, we are providing you with lots of resources and the
knowledge that comes from years of experience. Talking to some of the
thousands of students who took this course before you, here's some
advice that they found particularly useful:
-
Do not stress over grades: your goal is to learn new and
exciting things. Good grades follow naturally from deep learning
(but not necessarily vice versa). ...and employers care about what
you know not what grade you got.
-
Participate: you will get a lot more from this class if you
ask questions and engage with the course staff than if you are a fly
on the wall — and it will be more fun.
-
Manage your time wisely: allocate sufficient time for
homework and learning. Little adjustments can save you a whole lot
of time later and have a huge impact on your performance. In
particular, use class time to learn, review the material presented
in lecture the same day, and schedule time for homework
proactively.
-
Start homework early: racing against a deadline is so
stressful! Starting early will remove that stress, lead to deeper
learning and give you time to improve your solution if you feel like
it.
-
Get all the help you need: we provide plenty of resources
to help you succeed in this course
— office hours every
day, online help 24-7,
and friendly staff when you need them.
Take advantage of them: they are there for you! The only thing we
ask is that you plan a bit ahead: helping students takes time and
there are not enough of us if everybody waits up to the deadline.
-
Make time for fun: take a break from studying at least once
a day — meet with friends, go for a walk, play sports,
whatever gets you to reset your mind.
Feedback
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 we are not aware about a problem, we won't know to
fix it. If you would like to provide anonymous comments, please
use
the feedback form on the course home page.
Resources
Course Material
There is no textbook for this course. Lecture notes and other
resources are provided through
the
Schedule tab of this page and
on
. We do not require
students to read lecture notes before lecture, but those who are
interested in reading ahead can certainly do so.
The C0 Language
For most of the course, we
use
C0, a safe subset of C
augmented with contracts. This language has been specifically
designed to support the
learning objectives in this
course. It provides garbage collection (freeing students from
dealing with low-level details of explicit memory management), fixed
range modular integer arithmetic (avoiding complexities of floating
point arithmetic and multiple data sizes), an unambiguous language
definition (guarding against undefined behavior), and contracts
(making code expectations explicit and localizing reasoning).
The C Language
Towards the end, the course transitions to C in preparation for
subsequent systems courses. Emphasis is on transferring positive
habits developed with the use of C0, and on practical advice for
avoiding the pitfalls and understanding the idiosyncrasies of C. We
use the
valgrind tool to
test proper memory management.
Programming Environments
You are welcome to use any programming environment that suits you to
write your programming assignments. However, all programming homework
will be graded by running them on a Unix system
using
Autolab — you may want to
make sure they work
on
Andrew
Unix. Popular environment choices
include
emacs,
vim,
VSCode,
and
sublime, but you should
use what works for you: an environment that allows you to write code
quickly and efficiently. Here are some useful links:
Grading
This is a
10 unit course.
Tasks and Percentages
- 25 homework assignments: 45%
- 12 weekly written assignments: 15% (due
on Gradescope at 2pm EDT Monday
and Fridays, see calendar for exceptions)
- 12 weekly programming assignments: 30% (due
on Autolab at 11pm EDT Wednesday and
Saturday, see calendar for exceptions)
To encourage good work and integrity, the instructors may invite students to their offices to explain their solutions. Should this happen, the students' explanations will become part of their grades for that homework.
- Assignments are individual unless explicitly instructed.
- 2 midterm exams: 12.5% each, in class, closed books, on and
- Final exam: 25%, 3 hours, closed books, on
- Practice sessions and activities: 5%
Each lab-style practice session is graded on a 0-4 point scale, assigned as follows:
- 4 points for completing bonus exercises
- 3 points for completing standard exercises
- 1.5 point for attending and working on exercises, but not making it to the 2-point cutoff
- 0 points for not attending or not working on exercises
Each recitation-style practice session is NOT graded.
There will be one activity worth 1 point during or after each lecture. Use the activities page to test your configuration and do the current activity (if there is one).
Each lab you attend gives you 1.5 points, assuming you pay attention and work on the exercises.
All you need 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 miss a practice session or two. Do the math: the course has
- 12 graded practice sessions
- Activities on most days
We are aiming to have homework and exams graded within two days of submission.
Accessing and Monitoring your Grades
Posted grades are accessible by clicking on the
Grades
tab of this page. After authenticating, you will be able to see your
current grades and a projection of where you are headed given your
past performance in the class. Use this application to take action if
the trajectory does not lead to the grade you are hoping for.
Evaluation Criteria
Your assignments and exams are evaluated on the basis of:
-
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 the Guide to Success on Coding
with Style on
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 3 days of the homework 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.
Late Policy
This is a fast-paced course. The late policy has the purpose to help
students from falling behind.
Aside from this, there will be no extensions on assignments in
general. If you think you really
really need an extension on
a particular assignment,
contact the
instructors as soon as possible and before the deadline.
Please be aware that extensions are entirely discretionary and will be
granted only in exceptional circumstances outside of your control
(e.g., due to severe illness or major personal/family emergencies, but
not for competitions, club-related events or interviews). The
instructors will require confirmation from University Health Services
or your academic advisor, as appropriate.
Nearly all situations that make you run late on an assignment homework
can be avoided
with proper planning
— often just starting early. Here are some examples:
-
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.
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. If you notice any grading mistakes, proceed as follows:
-
Blatant grading mistakes (e.g., the rubric says X, and you wrote X
exactly) can be corrected by any TA
in office hours.
-
For any other grading issues, you must request a regrade:
Write an email to
explaining where and why you think there was a mistake in grading.
Make sure to specify which homework or exam this appeal is for.
Write at most 3 lines for each response you are disputing.
Email requests to the course staff will not be accepted. Please do
not make regrade requests on
.
All regrade requests must be received within 3 days of the work
being handed back on Gradescope
or Autolab, which we will announce in
a post.
Final Grades
This class is not curved. However, to ensure consistency across
semesters, we set our grading standards in such a way as to compensate
for the relative difficulty of exams.
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 about the
correlation between final grades and total scores:
- A: above 90%
- B: 80-90%
- C: 70-80%
- D: 60-70%
This assumes that the makeup of a student’s grade is not wildly
anomalous: exceptionally low overall scores on exams, programming
assignments, or written assignments will be treated on a case-by-case
basis. In particular, students who are unable to demonstrate a basic
proficiency with the C language in the last few programming
assignments will receive a D in the class (this is because 15-122 is a
prerequisite to 15-213, a very C-intensive course).
For reference, almost a quarter of the students who received a B in
Fall 2014 had a 90-100% average on programming assignments, an 80-90%
average on written homeworks, and a 70-80% average on exams.
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 practice sessions, exam performance and overall grade
trends when assigning the final grade.
Academic Integrity
You are expected to comply with the
University Policy on Academic Integrity (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).
The Policy (Summer'22)
You are allowed to clarify the writeup of homework assignments
with other students, but not work on a solution or brainstorm
answers with them.
You are welcome to freely discuss course material (lecture
notes/slides, practice exams, lab handouts, recitation handouts, blank
writtens and programming writeups) as well as to review graded
assignments with students taking the course in the current semester.
You may give or receive help with computer systems, compilers,
debuggers, profilers, or other facilities (as long as answers and/or
code are never visible).
You are not allowed to refer to solutions and/or code written by past
or present students, or found on the web, not even to "double-check"
your own solution. You may not post code from this course publicly
(e.g., to Bitbucket or GitHub).
You are not allowed to use any materials from previous iterations of the
course, including your own. You may not discuss or receive help on
homework assignments with students who have previously taken the
course (excluding current TAs).
We will be using the MOSS system to detect software plagiarism. Whenever a programming assignment is similar to a homework from a previous course edition, we will run MOSS on all submissions from that edition as well. All solutions from the Web are also in MOSS - you should assume that if you were able to find it, we have already found them.
If you are uncertain whether your actions will violate this policy, please reach out to a member of course staff to ask beforehand.
Penalties and Specifics
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 or by negligence 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 (written assignment,
programming assignment, midterm or final exam) must be your own
work. In the event that you use information written by others 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, copy or
adapt others' solutions, or sit near another person who is taking (or
has taken) the same course and complete the assignment together.
Working on code together, showing code to another student and looking
at another student's code are considered cheating. If you need help
debugging, go to office hours or make a
post on . 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.
Repeat Students
If you took this course in full or in part in a past semester, we ask
that you delete your previous work so you won't look at it. In
particular, copying one's own solutions from an earlier semester is a
violation of the academic integrity policy and will be handled as
such. Doing so may save time close to a deadline but it will not have
the effect of learning the material, which will be a serious handicap
in exams.
Other Policies
Class presence and participation
Active participation by you and other students will ensure that
everyone has the best learning experience in this class. We may take
participation in lecture and practice sessions into account when
setting final grades. Fire safety rules require that we never
exceed the stated capacity of a classroom or cluster. For this
reason, we require that you attend the lecture, lab, and recitation
you are registered for.
Laptops and mobile devices
As research on learning shows, unexpected noises and movement
automatically divert and capture people's attention, which means you
are affecting everyone's learning experience if your cell phone,
pager, laptop, etc, makes noise or is visually distracting during
class. Therefore, please silence all mobile devices during class. You
may use laptops for note-taking only, but please do so from the back
of the classroom. Do not work on assignments for this or any other
class while attending lecture or practice sessions.-->
Students with disabilities
If you wish to request an accommodation due to a documented
disability, please inform your instructor and
contact
Disability
Resources as soon as possible
(). Once your accommodation has been approved, you
will be able to request extra-time for each exam separately
by
filling this
form a week in advance.
Research to Improve the Course
For this course, we are conducting research on student learning. This
research will involve your coursework. You will not be asked to do
anything above or beyond the normal learning activities and
assignments that are part of this course. You are free not to
participate in this research, and your participation will have no
influence on your grade for this course or your academic career at
CMU. If you choose not to participate in the research, you must still
complete all required coursework, but your data will not be included
in the research analyses. Participants will not receive any
compensation. The data collected as part of this research will include
student grades. All analyses of data from participants' coursework
will be conducted after the course is over and final grades are
submitted. The Eberly Center
may provide support on this research project regarding data analysis
and interpretation. To minimize the risk of breach of confidentiality,
the Eberly Center will never have access to data from this course
containing your personal identifiers. All data will be analyzed in
de-identified form and presented in the aggregate, without any
personal identifiers. Please contact Dr. Chad Hershock
() or us if you
have questions or concerns about your participation.
Getting Help
Personal Health
Take care of yourself.
Do your best to maintain a healthy lifestyle this semester by eating
well, exercising, avoiding drugs and
alcohol, getting
enough sleep and taking some time to relax. This will help you
achieve your goals and cope with stress.
All of us benefit from support during times of struggle. You are not
alone. There are many helpful resources available on campus and an
important part of the college experience is learning how to ask for
help. Asking for support sooner rather than later is often helpful.
If you or anyone you know experiences any academic stress, difficult
life events, or feelings like anxiety or depression, we strongly
encourage you to seek support. Counseling and Psychological Services
(CaPS) is here to help: call 412-268-2922 and visit
their website. Consider
reaching out to a friend, faculty or family member you trust for help
getting connected to the support that can help.
If you or someone you know is feeling suicidal or in danger of
self-harm, call someone immediately, day or night:
- 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
If you have questions about this or your coursework, please
let us know.
Communication
For assistance with the written or oral communication assignments in
this class, visit the Global Communication Center (GCC). GCC tutors
can provide instruction on a range of communication topics and can
help you improve your papers and presentations. The GCC is a free
service, open to all students, and located in Hunt library. You can
make tutoring appointments directly on the
GCC
website.
You may also visit the GCC website to find out about communication
workshops offered throughout the academic year.
External Academic Support
The
Office of Academic
Development is providing various services aimed at helping
students master the contents of this course. These optional
services are free and voluntary. They are led by trained
leaders who have successfully completed the course. Leaders are not
members of the course staff. These services are are designed to supplement
— not replace — class lectures and recitations. They do
not cover homework.
We ask that students do not seek help from upperclassmates who
have successfully completed the course. Doing so often leads to
violations of the academic integrity policy of the
course. In particular, upper-classmates found to violate this
policy will be reported and will incur a grade penalty.
Learning Objectives
Computational Thinking
Students who complete this course should be able to explain
abstraction and other key computer science concepts, apply these
fundamental concepts as problem-solving tools, and wield contracts as
a tool for reasoning about the safety and correctness of programs. In
particular, we expect students to be able to:
- 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.
Programming Skills
Students who complete this course should be able to read and write
code for imperative algorithms and data structures. In particular, we
expect students to be able to:
- 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,
- generic data structures using void and function pointers,
- 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.
Algorithms and Data Structures
Students who complete this course should be able to describe the
implementation of a number of basic algorithms and data structures,
effectively employ those algorithms and data structures, and explain
and interpret worst-case asymptotic complexity arguments. In
particular, we expect students to be able to:
- determine the big-O complexity of common code patterns.
- compare common complexity classes like O(1), O(log n), 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.