Computer Science 109:
Computers in Our World

Fall 2021

Princeton University

Brian Kernighan

Computer Science Dept.
Thu Dec 23 07:16:16 EST 2021
Problem sets, labs and announcements will be posted on this web page only.
You are responsible for monitoring this page.

2021 final exam answers

Lecture notes:    9/1     9/8     9/13     9/15     9/20     9/22     9/27     9/29     10/4     10/6     10/11     10/13     10/25     10/27-11/1     11/3     11/8     11/10     11/15     11/17     11/22     11/29     12/1     12/6    

Problem sets:    1         2         3         4         5         6         7         8        

Solutions:    1         2         3         4         5         6         7         8        

Labs:        1         2         3         4         5         6         7         8        

Office hours:    BWK: MW after class; W 3:30-5:00 CS 311; F 2:00-4:00 (Zoom for now; use WASE)
                           Archie McKenzie '24 (archiem@) Wed and Sun 6:00-9:00

Old stuff:    playlist     survey     certificate in Technology and Society     Color demonstration program     Toy simulator     Lab 1 pages     Lab 2 pages     Turing machine simulator     Tower of Hanoi simulator     Students don't understand file systems     Why were Facebook/Instagram/WhatsApp down?       Facebook's explanation     Lab 3 pages     xkcd on big numbers     2019 midterm     (answers)       2020 midterm     (answers)       midterm answers       practice problems       paper on P=NP       Alternative to Colab       Python examples       online advertising       COS 126 info       Intel 8086 processor       How to make a CPU       Enigma simulator       Lab 6 comments       ATM / ISBN checker       "Securing your digital life"       Lab 7 web pages       New top500 list       Lab 8 comments       Cell phone surveillance article       Course summary       2020 final exam       2020 answers       2019 final exam       2019 answers      

Quick links:    Course summary, schedule and syllabus       Textbook       Problem sets       Labs       Lateness policy       Collaboration policy       Exams and grades

Course Summary

Computers, computing, and the many things enabled by them are all around us. Some of this is highly visible, like laptops, phones and the Internet; much is invisible, like the computers in gadgets and appliances and cars, or the programs that fly our planes and keep our telephones and power systems and medical equipment working, or the myriad systems that quietly collect, share and sometimes reveal vast amounts of personal data about us.

Even though most people will not be directly involved with creating such systems, everyone is strongly affected by them. COS 109 is intended to provide a broad high-level understanding of how hardware, software, networks, and systems operate. Topics will be motivated by current events and concerns, and will include discussion of how computers are built and operate; programming and programming languages; the Internet and the Web; artificial intelligence and machine learning; cryptography; and how all of these affect privacy, security, property and other important issues. We will also touch on fundamental ideas from computer science, and some of the inherent limitations of computers.

This course is meant for humanities and social sciences students who want to understand how computers and communications systems work and how they affect the world we live in. No prior experience with computers is assumed, and there are no prerequisites. COS 109 satisfies the QCR (née QR) requirement.

The labs are complementary to the lectures, though intended to reinforce the basic ideas. They will cover a spectrum of practical applications; two of the labs are a gentle introduction to programming in Python.

The course will have fundamentally the same structure as in previous years, but lectures, case studies and examples change every year according to what's happening. Stunning amounts of our private lives are observed and recorded by social networks, businesses and governments, mostly without our knowledge, let alone consent. Companies like Amazon, Apple, Facebook, Google and Microsoft are duking it out with each other on technical and legal fronts, and with governments everywhere. Shadowy groups and acronymic agencies routinely attack us and each other; their potential effect on things like elections and critical infrastructure is way beyond worrisome. The Internet of Things promises greater convenience at the price of much greater cyber perils. The careless, the clueless, the courts, the congress, the crazies, and the criminal (not disjoint groups, in case you hadn't noticed) continue to do bad things with technology. What could possibly go wrong? Come and find out.


Schedule (subject to change)

	Su Mo Tu We Th Fr Sa
Sep	          1  2  3  4	first class
	 5  6  7  8  9 10 11	no class on Monday (Labor Day)
	12 13 14 15 16 17 18	pset 1, lab 1 (due Wed 15, Sun 19)
	19 20 21 22 23 24 25	pset 2, lab 2 (and so on)
	26 27 28 29 30		pset 3,
Oct	                1  2	        lab 3
	 3  4  5  6  7  8  9	pset 4, lab 4
	10 11 12 13 14 15 16	open-book takehome midterm exam (no pset, no lab)
	17 18 19 20 21 22 23	fall break
	24 25 26 27 28 29 30	pset 5, lab 5
Nov	    1  2  3  4  5  6	pset 6, lab 6
	 7  8  9 10 11 12 13	pset 7, lab 7
	14 15 16 17 18 19 20	pset 8, lab 8
	21 22 23 24 25 26 27	Thanksgiving
	28 29 30
Dec	          1  2  3  4
	 5  6  7  8  9 10 11	last class
	12 13 14 15 16 17 18	Dean's date; open-book takehome final exam Dec 15-20
	19 20 21 22 23 24 25
	26 27 28 29 30 31



This will evolve over the semester, so check it out from time to time.

Sep 1:    Overview and introduction
Readings: (1) Introduction and Chapter 1 of Understanding the Digital World: What is a computer? (2) A famous 1945 Atlantic Monthly article by Vannevar Bush,
As we may think, is often cited as predicting the Internet and the web. How does Bush's "Memex" relate to Google and your computer? What did Bush get right 75 years ago, and what did he totally miss?

Sep 8:    What's in a computer?
Readings: (1) Preliminary discussion of the logical design of an electronic computing instrument. Original article by Burks, Goldstine and von Neumann. The first page is a clear description of how computers are organized, though in archaic terminology. There's no need to read beyond that, though section 3 is also quite germane. (2) Sections 4 and 5 of Alan Turing's famous essay on whether machines can think, Computing machinery and intelligence, provide an alternative description of how machines operate, not nearly so detailed as von Neumann's.

Sep 13, 15:    Representation of information
Readings: (1) Chapter 2 of Understanding the Digital World: Bits, bytes, representation of information.
Problem set 1, due Sep 15
Lab 1: HTML and web page design, due Sep 19

Sep 20, 22:    Inside the processor
Readings: (1) Chapter 3 of Understanding the Digital World: Inside the processor. (2) The original article on Moore's Law.
Problem set 2, due Sep 22
Lab 2: Advanced HTML, due Sep 26

Sep 27, 29: Software and algorithms   
Readings: Chapter 4 of Understanding the Digital World: Algorithms
Problem set 3, due Sep 29
Lab 3: Graphics, due Oct 3

Oct 4, 6: Programming and programming languages   
Readings: (1) Chapter 5 of Understanding the Digital World: Programs and programming languages.
(2) There are endless Python tutorials. Do a bit of searching and exploration.
Problem set 4, due Oct 6
Lab 4: Spreadsheets, due Oct 10

Oct 11, 13: Software systems   
Readings: Chapter 6 of Understanding the Digital World: Software systems.
Take-home midterm exam this week. There will (probably) be a Q/A session (probably) on Oct 10 (probably) at 4pm.   
No lab or problem set this week.

[Oct 18-22: fall break]

Oct 25, 27:    Intellectual property
Readings: (1) Sections 5.4 through 5.6 of Understanding the Digital World. (2) The first dozen or so pages of Google v. Oracle, the final [we hope] resolution of a decade-long case about software copyrights. (3) Chapter 7 of Understanding the Digital World; focus on the Python sections.
Problem set 5, due Oct 27
Lab 5: Python, due Oct 31

Nov 1, 3:    Communications: networks and the Internet
Readings: (1) Chapters 8 and 9 of Understanding the Digital World: Networking; The Internet. (2) Skim some of the Internet history papers. (3) Ed Felten's explanation of net neutrality.
Problem set 6, due Nov 3
Lab 6: Python and NLP, due Nov 7

Nov 8, 10:    World Wide Web
Readings: (1) Chapter 10 of Understanding the Digital World: The world wide web. (2) The original technical paper describing Google. Skip the hard bits, but get the insights. Note the comments about advertising in Appendix A.
Problem set 7, due Nov 10
Lab 7: AI and ML, due Nov 14

Nov 15, 17:    Artificial intelligence, machine learning
Readings: (1) Chapter 11 of Understanding the Digital World: Data and Information; (2) Chapter 12 of Understanding the Digital World: Artificial Intelligence and Machine Learning.
Problem set 8, due Nov 17
Lab 8: Privacy, due Nov 21

Nov 22:    Cryptography; compression and error detection
Readings: (1) Chapter 13 of Understanding the Digital World, Privacy and security. (2) New York Times Privacy Project

Nov 25, 27:    Catch-up; blockchains and cryptocurrencies; wireless; etc.

Dec 6:    Wrapup

[Reading period: Dec 7-14]

Q/A session some enchanted evening (Dec 12 4:30 Friend 008)

Dec 15-20:    Take-home final exam during Dec 15-20


Administrative Information

Professor: Brian Kernighan, 311 CS Building,

Office hours: to be determined

Lectures: Monday and Wednesday, 1:30-2:50, Friend 008.

Regular class attendance is expected and class participation helps. Frequent absences are grounds for a failing grade regardless of other performance.

No laptops, phones or tablets are permitted in lectures except for taking notes and other class purposes. Regrettably, computers and phones appear to be primarily used for mail, chat, YouTube, Twitter, Google, solitaire, poker, eBay, Facebook, Instagram, Snapchat, and similarly compelling diversions, all of which distract you, your neighbors, and me. (Additions to this list are welcome; I can't keep up.) This paper by Clay Shirky makes the case for banning distractors.

Textbook and Readings:

The primary text for the course is Understanding the Digital World, second edition ("UDW"). The first edition is still floating around. It doesn't have the new sections on Python nor the new chapter on AI and ML, but otherwise it's fine; use it if you like. If you are particularly interested in privacy and security, Bruce Schneier's Data and Goliath is highly recommended.

Notes and readings will be posted online. The weekly readings beyond the text are for background, context, general education, and/or entertainment; you are not expected to know the detailed content, but you should understand the basic ideas. Anything in UDW is fair game, however.

Problem sets:

Eight problem sets, together worth about 20 percent of the course grade, will be assigned. Problems are intended to be straightforward, reinforcing material covered in class and providing practice in quantitative reasoning, and should take 2-3 hours to complete.

Problem sets are due by midnight Wednesday, one week after they are assigned.


Eight labs, together worth about 20 percent of the course grade, will give hands-on practice in important aspects of computing. The labs are designed to be easily completed within 2-3 hours, if you have read through the instructions beforehand, which should take at most an hour. You can do the labs wherever you want, but if you need assistance, there are undergrad lab TAs who also support COS 126, 217 and 226. Further information about the lab TAs and clusters will be posted.

Labs are due by midnight Sunday of the week they are assigned.

Lateness policy:

In fairness to everyone, only reduced credit can be given for late submissions unless there are extraordinary circumstances, and in no case after solutions have been posted or discussed in class. For both labs and problem sets, heavy workloads in other classes don't count as "extraordinary," no matter how unexpected or important or time-consuming. I am also unsympathetic to the appeal that "this is my fifth class," since the same could be said of any one of your other classes.

If you do submit your work late, we will give you credit for it on this scale:

Regardless, you must turn in all problem sets and labs to pass the course.


If you find yourself in a tough situation, please let me know; help of various kinds is always available.


Collaboration policy:

You are encouraged to collaborate on problem sets, but you must turn in separate solutions; the names of all collaborators must appear on each submission.

(This elaboration of the policy on collaboration is paraphrased from COS 126:) You must reach your own understanding of the problem and discover a path to its solution. During this time, discussions with friends are encouraged. However, when the time comes to write down the solution to the problem, such discussions are no longer appropriate -- the solution must be your own work, so you must work on the written assignment on your own. If you have a question, you can certainly ask friends or teaching assistants, but do not, under any circumstances, copy another person's work or present it as your own. This is a violation of academic regulations, for which the penalties are draconian.

Another way to look at this: If I ask you to explain how you got your answer, you will have no trouble doing so, because you understand the material completely.

As it is for problem sets, so it is for labs: collaboration to understand the material is encouraged, but the work you turn in has to be your own.

Exams and grades:

An open-book takehome midterm examination will be given during the week before fall break. It will cover material presented and discussed in class and any relevant reading through the end of the fifth week of classes. It will be worth 20 percent of the course grade.

An open-book takehome final examination will be given during the exam period. It will cover all material presented and discussed in class throughout the semester and any relevant reading. It will be worth about 35 percent of the course grade.

Sorry: no collaboration on exams.

There will be a question and answer session before each exam. Q/A sessions are not meant to be an orderly review and are not a substitute for missed lectures, but they are a chance for you to ask questions about course material.

If you do poorly on the midterm but much better on the final exam, I will weight the final more heavily than usual, so a poor midterm grade is not fatal at all. But you must do acceptably well on the final; students who cannot answer even half the questions should not be surprised to get a D, and an F is not impossible, especially if other work is also inadequate.

Don't forget that P/D/F has three possible outcomes, only one of which is good. Attending lectures, paying attention, participating, turning work in on time, coming to office hours, studying for exams, and attending Q/A sessions all help to avoid unpleasant results.