Lecture 10

The End

  • Big thanks to the American Repertory Theater for hosting lectures this term, providing amazing props, lighting, and sounds to our stage.
  • CS50’s team, too, has been making everything possible off-stage, including our teaching fellows and course assistants, at both Harvard and Yale.
  • And even David makes mistakes and can be unsure about answers for some questions, so rest assured that learning will continue well beyond this course.
  • Don’t forget that, ultimately:

    what ultimately matters in this course is not so much where you end up relative to your classmates but where you end up relative to yourself when you began

  • We’ve learned some first principles:
    • computational thinking
    • using algorithms to solve problems, given some inputs from which to produce outputs
    • axes of correctness, design, and style to evaluate our code
    • abstraction, using layering to simplify problems, as with functions in code
    • precision, as by considering all the possible edge cases in our instructions
  • With these basic building blocks, we can learn to use tools in the future, beyond C and Python, to solve even more problems.
  • We ask a volunteer to give a series of instructions for how to draw a cube and a snowman, and since everyone else interpreted each instruction slightly differently, the final drawings all ended up very different.

Ethics

  • We might think of ethics as whether we should do something, or how we go about doing it, even when we have the ability to.
  • For example, we can now use code to send lots of emails, creating more spam. We can collect passwords for our website with a form, and if a user uses that same password for another site, we end up with access to their account unless we store the passwords securely.
  • JavaScript, too, can be used to log users’ actions on our sites, like items they’ve added to their cart. But logging all actions, over time, can cause worry for users’ privacy.
  • Before Facebook, the website, there was another website, Facemash, where code was used to scrape, or download, images of Harvard students and use them without prior permission.
  • With some colleagues from the Department of Philosophy, Meica Magnani and Susan Kennedy, we discuss some frameworks for making decisions more rigorously.
  • The Embedded EthiCS program at Harvard integrates tools for ethical reasoning into computer science courses, to help ensure that future computer scientists will be creating and using technology ethically.
  • The transcript for this section of lecture, as well as readings for the related lab, have been posted separately.

Looking Forward

Quiz Show

  • We host a quiz show with the audience, with the following questions:
    • What are the steps for compiling source code into machine code?
      • Preprocessing, compiling, assembling, linking
    • What is the runtime of binary search?
      • O(log n)
    • Which of these animals was the first to be mentioned in a CS50 lecture?
      • Cat
    • Every time you malloc memory, you should also be sure to…
      • free
    • What is a race condition?
      • When two things happen at the same time and produce an unexpected result
    • Does zooming in on a photo let you “enhance” it to generate more detail?
      • No, a photo only has a certain amount of detail
    • Which of the following is not a characteristic of a good hash function?
      • Randomness
    • What does FIFO stand for?
      • First in, first out
    • Which of the following would represent pink using RGB values?
      • #ffd0e0
    • In C, which of the following lines of code allocates enough memory for a copy of the string s?
      • malloc(strlen(s) + 1)
    • How should you organize your clothes to be cool?
      • queue
    • What is a segmentation fault?
      • When a program tries to access memory that it shouldn’t
    • Which of the following types of overflow can result from recursion without a base case?
      • stack overflow
    • In the town of Fiftyville, what were the names of the three people who witnessed the rubber duck robbery?
      • Ruth, Eugene, and Raymond
    • Which of these command-line programs check your code for memory leaks?
      • valgrind
    • Which of the following exists in C, but not Python?
      • do-while loops
    • What HTTP request method should you use when sending private information, like a password?
      • POST
    • What data structure allows for constant-time lookup for words in a dictionary?
      • trie
    • What is a cookie?
      • both of the above
    • What’s your comfort level now?
      • I’m among those more comfortable
  • Thanks for joining us at CS50!