Computer Science 109:
Computers in Our World

Fall 2023

Princeton University

Brian Kernighan

Computer Science Dept.
Fri Dec 29 11:27:45 EST 2023

23 final answers

Problem sets, labs and announcements will be posted on this web page only.
You are responsible for monitoring this page.

Lecture notes:    9/6     9/11     9/13     9/18     9/20     9/25     9/27     10/2     10/4     10/9     10/11     10/23     10/25     10/30     11/1 11/6     11/8     11/13     11/15     11/20     11/27     11/29     12/4     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: Mon and Wed after class; other in-person or Zoom times can be easily arranged.
                           Archie McKenzie '24 (archiem@) Wed 3:00-6:00 and Sun 6:00-9:00 Zoom link
                           Anika Maskara '23 (amaskara@) Tue 4:00-6:00 and Fri 2:00-4:00 Zoom 8908173365
                           (Other times can be arranged for all of us; send mail.)

Old stuff:    playlist     Survey     NYT on face recognition     iPhone popularity     Babbage Difference Engine     Ada Lovelace     Eric Schmidt '76 on Generative AI     Lab 1 pages     US News rankings     Why you don't want to use ChatGPT for problem sets     Binary numbers in the comics     How big should an integer be?     Colormap program     RGB colors     Lab 2 pages     Toy simulator     HN on As We May Think     Lab 3 pages     XKCD on factorial bases     2022 midterm     2022 midterm answers     2021 midterm     2021 midterm answers     Python examples     How to make a CPU     2023 midterm answers     Apple Watch patents     The Myth of "Anonymous" Data     Data brokers     Lab 6 books     What FB knows about you     ATM and ISBN checker     Lab 7 pages     Frequency Allocation chart     Spam filtering     Summary of what we covered     22 final exam     22 final answers         21 final exam     21 final answers

Quick links:    Course summary, schedule and syllabus       Textbook       Problem sets       Labs       Lateness policy       Collaboration policy       ChatGPT 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 cover a spectrum of practical applications; some 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 sudden arrival of ChatGPT and the like has changed the way we think about artificial intelligence. 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  5  6  7  8  9	first class
	10 11 12 13 14 15 16	pset 1 due Wed 13, lab 1 due Sun 17
	17 18 19 20 21 22 23	pset 2, lab 2 due Wed 20, Sun 24
	24 25 26 27 28 29 30	pset 3, lab 3 (and so on)
Oct	 1  2  3  4  5  6  7	pset 4, lab 4
	 8  9 10 11 12 13 14	open-book take-home midterm exam (no pset, no lab)
	15 16 17 18 19 20 21    fall break
	22 23 24 25 26 27 28	pset 5, lab 5
	29 30 31
Nov	          1  2  3  4	pset 6, lab 6
	 5  6  7  8  9 10 11	pset 7, lab 7
	12 13 14 15 16 17 18	pset 8, lab 8 (no more psets or labs after this)
	19 20 21 22 23 24 25    Thanksgiving
	26 27 28 29 30
Dec	                1  2
	 3  4  5  6  7  8  9	last class
	10 11 12 13 14 15 16	Dean's date; open-book take-home final exam Dec 16-21
	17 18 19 20 21 22 23
	24 25 26 27 28 29 30


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

Sep 6:    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 11, 13:    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. You might also see how well ChatGPT does on his original Turing test.
Problem set 1, due Sep 13
Lab 1: HTML and web page design, due Sep 17

Sep 18, 20:    Representation of information
Readings: (1) Chapter 2 of Understanding the Digital World: Bits, bytes, representation of information.
Problem set 2, due Sep 20
Lab 2: Advanced HTML, due Sep 24

Sep 25, 27:    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 3, due Sep 27
Lab 3: Graphics, due Oct 1

Oct 2, 4: Software and algorithms   
Readings: Chapter 4 of Understanding the Digital World: Algorithms
Problem set 4, due Oct 4
Lab 4: Spreadsheets, due Oct 8

Oct 9, 11: 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.
No lab or problem set this week.
Take-home midterm exam this week. Q/A session (probably) on Oct 8 (probably) at 4pm (probably).   

[Oct 16-22: fall break]

Oct 23, 25: Software systems   
Readings: Chapter 6 of Understanding the Digital World: Software systems.
Problem set 5, due Oct 25
Lab 5: Python, due Oct 29

Oct 30, Nov 1:    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 6, due Nov 1
Lab 6: Python and NLP, due Nov 5

Nov 6, 8:    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 7, due Nov 8
Lab 7: AI and ML, due Nov 12

Nov 13, 15:    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 8, due Nov 15
Lab 8: Privacy, due Nov 19

Nov 20:    Artificial intelligence and machine learning
Readings in UDW: (1) Chapter 11, Data and Information; (2) Chapter 12, Artificial Intelligence and Machine Learning.

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

Dec 4, 6:    Blockchains and cryptocurrency. Wireless

[Reading period: Dec 9-16]

Q/A session some enchanted evening (somewhere)

Dec 16-21:    Take-home final exam during Dec 16-21

Administrative Information

Professor: Brian Kernighan, 311 CS Building,

Office hours: after class, or by appointment; just send mail

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, WhatsApp, TikTok, 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.)

Textbook and Readings:

The primary text for the course is Understanding the Digital World, second edition ("UDW"). Labyrinth's warehouse sells it for less than Amazon and I encourage you to support our excellent local bookstore.

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 1-2 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.


This semester, we will be using Gradescope to handle all pset and lab submissions. If you need to sign up for a Gradescope account, please use your email address. If you are enrolled in this course, you should see COS 109 under "Your Courses" when you log into Gradescope using an account associated with your Princeton email.

You can also log in through Gradescope using your netid. Navigate to, go to "Log in," and log in with school credentials (Princeton University NetID). This part is not as obvious as it could be.

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.

ChatGPT and Generative AI policy:

Do not use ChapGPT and the like for problem sets. Otherwise, use them at your own risk. My sense is that such programs can be helpful in explaining concepts, they can often produce "how-to" information, and they can generate code that is often correct. But currently they seem to be bad at arithmetic, and they may produce confident but total nonsense. Your mileage may differ, of course, and the field is moving fast.

Exams and grades:

An open-book take-home 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 take-home 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 will all help to avoid unpleasant results.