Computer Science 109:
Computers in Our World

Fall 2018

Princeton University

Brian Kernighan

Computer Science Dept.

Mon Jan 21 10:15:22 EST 2019
Answers for final exam

Lecture notes:    9/12    9/17    9/19    9/24-26    10/1    10/3    10/8    10/10    10/15    10/17    10/22-24    11/5,7    11/12    11/12,14    11/19    11/26    11/28-12/3    12/5    12/10   

Problem sets:    1         2         3         4         5         6         7         8        

Labs:        1         2         3         4         5         6         7         8        

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

Old stuff:    playlist     lab session information     survey     survey results     Society & Ethics of CS     Technology and Society certificate     binary converter program     color map program     Toy simulator     Hennessy and Patterson Turing Award lecture     Turing machine simulator     lab 2 pages     lab 3 pages     2014 midterm   (answers)     2013 midterm   (answers)     practice problems     map-folding problem     Javascript samples     GNU GPL (General Public License)     2018 midterm answers     Lady Trumpington obituary     lab 5 web pages     lab 6 web pages     Alice&Bob&Eve     RSA     Real-world crypto     original Tor paper     ATM and ISBN checksum code     2013 final   (answers)     2014 final   (answers)     cellphone tracking     Spectrum allocation chart    

Quick links:    Course summary, schedule and syllabus       Office hours       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, tablets, 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 leak 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; machine learning and big data; cyber-warfare; and how all of these affect security, privacy, property and other 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 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 Javascript.

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. Major companies like Amazon, Apple, Facebook, Google and Microsoft are duking it out with each other on technical and legal fronts, and with a variety of governments. Shadowy groups and acronymic agencies routinely attack us and each other. The Internet of Things promises greater convenience at the price of much greater cyber perils. Skirmishes in the forever war between students and the entertainment industry affect Princeton students all the time. The careless, the clueless, the courts, the congress, and the criminal continue to do bad things with technology. What could possibly go wrong? Come and find out.



	Su Mo Tu We Th Fr Sa
  Sep	                   1
	 2  3  4  5  6  7  8
	 9 10 11 12 13 14 15	first class
	16 17 18 19 20 21 22
	23 24 25 26 27 28 29	problem set 1, lab 1
  Oct	    1  2  3  4  5  6	problem set 2, lab 2
	 7  8  9 10 11 12 13	problem set 3, lab 3
	14 15 16 17 18 19 20	problem set 4, lab 4
	21 22 23 24 25 26 27	take-home midterm exam handed out; due Friday 10/26 at 4pm
	28 29 30 31		fall break
  Nov	             1  2  3
	 4  5  6  7  8  9 10	problem set 5, lab 5
	11 12 13 14 15 16 17	problem set 6, lab 6
	18 19 20 21 22 23 24	Thanksgiving
	25 26 27 28 29 30	problem set 7, lab 7
  Dec	                   1
	 2  3  4  5  6  7  8	problem set 8, lab 8
	 9 10 11 12 13 14 15	last class
	16 17 18 19 20 21 22	winter break
	23 24 25 26 27 28 29
	30 31
  Jan	       1  2  3  4  5
	 6  7  8  9 10 11 12
	13 14 15 16 17 18 19	1/15: Dean's date; 1/17: final exam 7:30 pm, Peyton 145
	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.

Week 0: Sep 12:    Warmup
Readings: 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 70+ years ago, and what did he totally miss?

Week 1: Sep 17, 19:    What's in a computer; how does a computer work
Readings: Chapter 1 of Understanding the Digital World: what's in a computer?

Week 2: Sep 24, 26:    Representation of information
Problem set 1, due Sep 26
Lab 1: HTML and web page design, due Sep 28
Readings: (1) Chapter 2 of Understanding the Digital World: bits, bytes, representation of information. (2) 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. (3) 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 so detailed as von Neumann's.

Week 3: Oct 1, 3:    What the components are and how they are made
Problem set 2, due Oct 3
Lab 2: Advanced HTML, due Oct 5
Readings: (1) Chapter 3 of Understanding the Digital World: Inside the CPU. (2) The original article on Moore's Law. (3) How Stuff Works has some pages on microprocessors.

Week 4: Oct 8, 10:    Software and algorithms
Problem set 3, due Oct 10
Lab 3: Graphics, due Oct 12
Readings: Chapter 4 of Understanding the Digital World: Algorithms

Week 5: Oct 15, 17:    Languages, programming; Javascript
Problem set 4, due Oct 17
Lab 4: Spreadsheets, due Oct 19
Readings: (1) Chapter 5 of Understanding the Digital World: Programs and programming languages. (2) A number of Javascript tutorials, out of many: Codecademy, Khan Academy, Javascript Kit. (3) You should also look at if programming interests you.

Week 6: Oct 22, 24:    Operating systems, file systems, databases, big data
Midterm exam handed out in class Oct 22. A Q/A session will be held on Oct 21.   
No lab or problem set this week.
Readings: Chapter 6 of Understanding the Digital World: Software systems.

[fall break]

Week 7: Nov 5, 7:    Javascript. Applications.
Problem set 5, due Nov 7
Lab 5: Javascript, due Nov 9
Readings: (1) Chapter 7 of Understanding the Digital World: Javascript. (2) Browse this 2008 study of NJ voting machine problems, a troubling place to encounter bad software development, and hope that nothing could possibly go wrong in an election year. (NJ voting machines have not been upgraded in the intervening decade.)

Week 8: Nov 12, 14:    Networks and communications, Internet
Problem set 6, due Nov 14
Lab 6: Javascript 2, due Nov 16
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.

Week 9: Nov 19:    World Wide Web
No problem set or lab this week.
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.

Week 10: Nov 26, 28:    Artificial intelligence, machine learning
Problem set 7, due Nov 28
Lab 7: Natural Language Processing and Machine Learning, due Nov 30
Readings: (1) Chapter 11 of Understanding the Digital World: Data and information. (2) Motherboard article on how to not be hacked. (3) James Fallows article on identity theft.

Week 11: Dec 3, 5:    Cryptography; compression and error detection
Problem set 8, due Dec 5
Lab 8: Privacy, due Dec 7
Readings: Chapter 12 of Understanding the Digital World, Privacy and security.

Week 12: Dec 10, 12:    Case studies, wrapup
No more labs or problem sets!

[winter break]

Q/A session some enchanted evening

January 17:    Final exam 7:30 pm, Peyton 145
Note that the final exam date is set by the registrar and I am not allowed to make any individual arrangements. Take this into account when making travel plans.
Registrar's Official Exam Schedule page.


Administrative Information

Professor: Brian Kernighan, 311 CS Building, 609-258-2089, Office hours are Monday 3:00-4:30 (right after class) and Tuesday 2:30-5:30, or by appointment, or just drop in if my door is open, which it usually is.

Teaching Assistant:   Sonali Mahendran, sonalim@. Office hours Thursday 9-11am, CS 003.

Lectures: Monday and Wednesday, 1:30-2:50, Lewis Library 138.

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 email, 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 ("UDW"), available at Labyrinth and Amazon. 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.

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 5:00 PM 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 will be undergrad lab TAs available in the clusters in Lewis Library Monday through Friday from 7-11PM, Saturday from 3-7PM and Sunday from 5-11PM. Further information about the lab TAs and clusters will be posted.

Labs are due by midnight Friday 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, extracurricular activities and heavy workloads in other classes don't count as "extraordinary," no matter how unexpected or important or time-consuming. And I am 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.

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 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 final examination will be given during the January exam period. It will cover all material presented and discussed in class throughout the semester and any relevant reading. It will be worth 35-40 percent of the course grade.

Sorry: no collaboration on take-home exams or the final.

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.