CS 161 - Introduction to Computer Science I

Winter 2020: MWF 2 - 2:50 p.m., LINC 228

Calendar

All items are tentative and subject to change

Date Lecture Assigned Reading Assignment Due Dates
Week #1
01/06 What this class offers you,
what your responsibilities are,
and how we communciate with computers
  • Lecture 1 slides
  • Rao Lesson 1 (pp. 1-15)
    Rao Lesson 2 (pp. 17-29)

    If you don't yet have the textbook, start here: MIT Lecture 1 or Miller Lecture 1
    01/08 How do we store information in a computer?
    What is good programming style?
  • Lecture 2 slides
  • Code demo: lec2-hello.cpp
  • Code demo: lec2-hello-ugly.cpp
  • Code demo: lec2-vars.cpp
  • Practice: Edabit Week 1
  • Fun: International Obfuscated C Code Contest
  • Rao Lesson 3 (pp. 31-47 + 58-59)
    or Miller Lecture 2
    01/10 How do computers interact with users?
    How do we calculate new information?
  • Lecture 3 slides
  • Code demo: lec3-const.cpp
  • Practice: Edabit Week 1
  • Rao Lesson 5 (pp. 85-91, 104-111)
    or MIT Lecture 2
    Assignment #1 due Sunday, 01/12 by 11:59 p.m. (TEACH)
    Week #2
    01/13 How do computers make decisions? (conditionals)
    How to design a program before writing code
    How can we guard against user mistakes?
  • Lecture 4 slides
  • Code demo: lec4-ifthen.cpp
  • Rao Lesson 5 (pp. 92-100)
    Rao Lesson 6 (pp. 113-127)
    01/15 More decision making (conditional statements)
    Assignment 2 Design and testing
    How do we handle invalid input?
    How can we generate random numbers?
  • Lecture 5 slides
  • Code demo: lec5-ifthen-ex2-interactive.cpp
  • Code demo: lec5-ifthen-ex3.cpp
  • Code demo: lec5-else.cpp
  • Code demo: lec5-scope.cpp
    (will cause a compiler error)
  • Code demo: lec5-scope-fixed.cpp
    (the error is fixed!)
  • Code demo: lec5-rand.cpp
  • Rao pp. 40 (Booleans)
    Rao pp. 41 (characters)
    Rao pp. 122-125 (switch statement)
    Random numbers
    01/17 How can we do something over and over and over? (loops)
    More decision making (conditional statements)
    Working with words and text (strings)
    Generating better random numbers
  • Lecture 6 slides
  • Code demo: lec6-string.cpp
  • Code demo: lec6-string-concat.cpp
  • Code demo: lec6-switch.cpp
  • Code demo: lec6-switch2.cpp
  • Code demo: lec6-rand.cpp
  • Code demo: lec6-rand-seed.cpp
  • Code demo: lec6-rand-seed-for.cpp
  • Code demo: lec6-rand-seed-while.cpp
  • Code demo: lec6-rand-seed-do-while.cpp
  • Rao Lesson 6 (pp. 128-142)
    Rao pp. 79-81 (strings)
    time()
    Escape sequences
    Miller Lecture 5
    Assignment #2 Design due Sunday, 1/19 by 11:59 p.m. (Canvas)
    Week #3
    01/20 No School, Martin Luther King, Jr. Day
    01/22 More ways to repeat computation with ease (loops)
    How can we catch and correct errors (bugs)?
  • Lecture 7 slides
  • Code demo: lec7-loops.cpp
  • Rao Lesson 6 (pp. 128-145)
    Miller Lecture 5
    Assignment #2 Peer Review due Wednesday, 01/22 by 11:59 p.m. (Canvas)
    01/24 What do we do when things go wrong?
    How can we use the same code in different places? (functions)
  • Lecture 8 slides
  • Code demo: lec8-assert.cpp
  • Code demo: lec8-bugs-before.cpp
  • Code demo: lec8-bugs-after.cpp
  • Code demo: lec8-functions.cpp
  • Rao Lesson 7 (pp. 151-158, 168-169)
    Assignment #2 due Sunday, 01/26 by 11:59 p.m. (TEACH)
    Week #4
    01/27 How do functions make programming easier?
  • Lecture 9 slides
  • Practice: Edabit Week 4
  • Code demo: lec9-user-for.cpp
  • Code demo: lec9-functions.cpp
  • Rao Lesson 7 (pp. 151-158, 168-169)
    Miller Lecture 3
    01/29 Preparing for Midterm #1
  • Lecture 10 slides
  • String functions
  • Code demo: lec10-string.cpp
  • Code demo: lec10-string-line.cpp
  • Past Exam I and Answers to Past Exam I
  • Past Exam II and Answers to Past Exam II
  • 01/30 Midterm #1 Review, 6-7 p.m. in KEC 1001
    01/31 Midterm #1 Assignment #3 Design due Sunday, 02/02, by 11:59 p.m. (Canvas)
    Week #5
    02/03 What we learned from Midterm #1
  • Lecture 12 slides
  • Midterm #1 solution
  • Code demo: lec12-flush.cpp
  • Code demo: lec12-cr.cpp
  • Code demo: lec12-backspace.cpp
  • 02/05 How can functions make persistent changes? (references)
  • Lecture 13 slides
  • Code demo: lec13-scope-practice-1.cpp
  • Code demo: lec13-scope-practice-2.cpp
  • Code demo: lec13-scope-practice-3.cpp
  • Code demo: lec13-reference.cpp
  • Code demo: lec13-reference-strings.cpp
  • Rao Lesson 7 (pp. 163, 166-167)
    Rao Lesson 8 (pp. 205-210)
    Assignment #3 Peer Review due Wednesday, 02/05 by 11:59 p.m. (Canvas)
    02/06 Study session (week 5) 6-7 p.m. in LINC 268
  • Worksheet 5 (print and complete, then bring to the study session)
  • Worksheet 5 solution
  • 02/07 Working with pointers
  • Lecture 14 slides
  • Code demo: lec14-max-reference.cpp
  • Code demo: lec14-reference-strings.cpp
  • Code demo: lec14-pass-pointer.cpp
  • Code demo: lec14-pointer-play.cpp
  • Rao Lesson 8 (pp. 177-186)
    Pointers vs. references
    References in C++
    Assignment #3 due Sunday, 02/09 by 11:59 p.m. (TEACH)
    Week #6
    02/10 Adapting when data storage isn't known in advance (dynamic memory allocation)
  • Lecture 15 slides
  • Code demo: lec15-pointer.cpp
  • Code demo: lec15-mem-errors.cpp
  • Rao Lesson 8 (pp. 187-204)
    Memory allocation: new and delete
    The stack and the heap
    Pass a reference to a pointer
    02/12 Review of references, pointers, and dynamic memory management
  • Lecture 16 slides
  • Code demo: lec16-divide-string.cpp
  • Code demo: lec16-stack-heap.cpp
  • Rao Lesson 8 (pp. 187-204)
    Memory allocation: new and delete
    The stack and the heap
    02/13 Study session (week 6) 6-7 p.m. in LINC 268
  • Worksheet 6 (print and complete, then bring to the study session)
  • Worksheet 6 solution
  • 02/14 Static arrays and C-style strings
  • Lecture 17 slides
  • Code demo: lec17-arrays.cpp
  • Code demo: lec17-play.cpp
  • Code demo: lec17-c-string.cpp
  • Rao Lesson 4 (pp. 63-71, 76-79)
    Rao Lesson 7 (pp. 165-166)
    C-style strings
    C-style string functions
    Assignment #4 Design due Sunday, 02/16, by 11:59 p.m. (Canvas)
    Week #7
    02/17 Using arrays with functions; dynamic arrays
  • Lecture 18 slides
  • Code demo: lec18-static-array.cpp
  • Code demo: lec18-pass-array.cpp
  • Code demo: lec18-arrays.cpp (static vs. dynamic)
  • Rao Lesson 7 (pp. 165-166)
    Rao Lesson 8 (pp. 189-198)
    02/19 Multidimensional arrays
  • Lecture 19 slides
  • Code demo: lec19-max-in-array.cpp
  • Code demo: lec19-dynamic-arrays.cpp
  • Code demo: lec19-2d-arrays.cpp
  • Code demo: lec19-tictactoe.cpp
  • Rao Lesson 4 (pp. 71-74)
    Rao Lesson 6 (pp. 145-146)
    Assignment #4 Peer Review due Wednesday, 02/19 by 11:59 p.m. (Canvas)
    02/20 Study session (week 7) 6-7 p.m. in LINC 268
  • Worksheet 7 (print and complete, then bring to the study session)
  • Worksheet 7 solution
  • 02/21 Create your own data types!
  • Lecture 20 slides
  • Code demo: lec20-pass-2D-arrays.cpp
  • Code demo: lec20-structs.cpp
  • Structs Assignment #4 due Sunday, 02/23 by 11:59 p.m. (TEACH)
    Week #8
    02/24 Divide and conquer: recursion
  • Lecture 21 slides
  • Code demo: lec21-factorial-iterative.cpp
  • Code demo: lec21-factorial-recursive.cpp
  • Code demo: lec21-power-recursive.cpp
  • Rao Lesson 7 (pp. 159-161)
    Miller Lecture 8
    02/26 Preparing for Midterm #2
  • Lecture 22 slides
  • 02/27 Midterm #2 Review, 6-7 p.m. in LINC 228
  • Example questions and Solutions
  • 02/28 Midterm #2 (different room: LINC 100) Assignment #5 Design due Sunday, 03/01, by 11:59 p.m. (Canvas)
    Week #9
    03/02 What we learned from Midterm #2
  • Lecture 24 slides
  • Midterm #2 solution, form 1
  • Midterm #2 solution, form 2
  • 03/04 Recursive data structures: linked lists
  • Lecture 25 slides
  • Code demo: lec25-pal-digits.cpp
  • Code demo: lec25-recur-structs.cpp
  • Miller Lecture 8 Assignment #5 Peer Review due Wednesday, 03/04 by 11:59 p.m. (Canvas)
    03/05 Study session (week 9) 6-7 p.m. in LINC 268
  • Worksheet 9 (print and complete, then bring to the study session)
  • 03/06 Recursive data structures: trees
  • Lecture 26 slides
  • Code demo: lec26-recur-train.cpp
  • Code demo: lec26-recur-tree.cpp
  • Miller Lecture 8 Assignment #5 due Sunday, 03/08 by 11:59 p.m. (TEACH)
    Week #10
    03/09 Command-line arguments
    How to read and write to files
  • Lecture 27 slides
  • Code demo: lec27-stack-heap.cpp
  • Code demo: lec27-recur-train-user.cpp
  • Code demo: lec27-recur-train-args.cpp
  • Code demo: lec27-files.cpp
  • Command-line arguments
    Miller Lecture 4 - file I/O
    03/11 C++ Programs in Space
  • Lecture 28 slides
  • NASA Lessons Learned
  • Cassini backups
  • Loss of MGS
  • 03/13 Review for the final exam
  • Lecture 29 slides
  • Lecture 29 recording with captions
  • Lecture 29 video (no captions)
  • Lecture 29 transcript
  • Example questions and Solutions
  • Assignment #6 due Saturday, 03/14 by 11:59 p.m. (TEACH)

    03/16 (Monday) Final Exam: 6:00 - 7:50 p.m. on Canvas