## Week 0 Wednesday Andrew Sellergren ### Announcements and Demos (0:00-8:00, 18:00-20:00) + [This](https://www.cs50.net/) is CS50! + David sat where you are sitting (approximately 150 years ago) as a freshman Government concentrator. Except, he wasn't in CS50. At the time, CS50 had the reputation of being very difficult. Though he had played with computers a lot in high school, David never really thought of himself as a "computer person" and didn't think he survive a hardcore programming course. When he decided to take CS50 sophomore year, he only did so Pass/Fail. Even Computer Science PhDs have humble beginnings! + If you don't believe me, consider last year's statistics: + 76% of the class had no prior experience in computer science before taking CS50 + 55% of the class identified themselves as being "less comfortable" with computer science, as compared to 10% who identified themselves as "more comfortable" and 35% who identified themselves as "somewhere in between" + You may have noticed a few extra cameras in here. In addition to taping lectures, they're being used to film a documentary about higher education. + CS50 will be the first course at Harvard offered through edX, a joint effort with MIT to bring online education to the masses. Speaking of masses: as of a few days ago, you have 53,018 online classmates. + In addition to Harvard undergraduates, we welcome students from HES, GSD, GSE, HBS, HKS, HLS, Belmont, Lexington, Newton, and Watertown to CS50! ### Intro to Computer Science (8:00-18:00, 20:00-35:00) + It's a common misconception that computer science is nothing more than programming. Programming is certainly a tool of computer science, but increasingly, it is also a tool for biologists, statisticians, etc. to analyze large amounts of data. #### The Famous Phonebook Example + Back in the days when phone numbers weren't stored in cell phones, you might have actually had to look them up in a phonebook. How did you go about that? If you wanted to look up someone with the last name "Smith," you could flip through the phonebook one page at a time. You don't need to be a computer scientist to know that this is an inefficient approach. + Instead, we could start by flipping to the middle of the phonebook. Now we break the problem into two. Since we know that "Smith" isn't in the left half of the alphabet, we can literally tear the phonebook in half, throw away the left half of the phonebook, and leave ourselves with only the right half. Once again, we flip to the middle and find ourselves at "R." We can again throw away the left half. As we continue tearing the book in half and throwing away pieces of it, we will eventually be left with a single page on which the name "Smith" appears (assuming it was there in the first place). + How do these two approaches compare in terms of their times to solve the problem? In the graph below, the first steep line (`n` in red) represents the approach of turning one page at a time. The second steep line (`n/2` in yellow) represents a slightly improved approach of turning two pages at a time. The curve (`log n` in green) represents our "tear and throw away" approach. As the size of the problem grows, the time to solve that problem doesn't grow nearly as fast. In the context of this problem, `n` is the number of pages in the phonebook. As we go from 500 to 1000 to 2000 pages in the phonebook, we need only tear the phonebook in half one or two more times. n and n/2 are much slower than log n. #### Our First Algorithm + Let's take a look at another problem: counting the number of students in this lecture hall. We can solve this problem using a very simple algorithm: 1. stand up and think of the number 1 2. pair off with someone standing, add your numbers together, and adopt the sum as your new number 3. one of you should sit down; the other should go back to step 2 + This algorithm gives us something close to the correct number of 705. Hooray! Another 700 people could walk into this room, but it would only take us a single extra iteration of this algorithm to count them as well. + If you like puzzles like this, check out [CS50 Puzzle Day](https://www.cs50.net/puzzles/)! #### Binary and Hard Drives + Even if you think you know nothing about computer science, you probably know that computers deal in 0's and 1's. These 0's and 1's comprise the binary system of numbers. Binary means "two," which is exactly how many numbers binary can represent. Why binary? If we have just two numbers, we can very easily represent them in the physical world using electricity. If a lightbulb is on, it represents 1. If a lightbulb is off, it represents 0. + Let's hear more about [binary](http://cs50.tv/2012/fall/shorts/binary/binary-720p.mp4) from our friend Nate Hardison. + As you can see, counting in binary is not all that different from counting in decimal. Computers simply use a different base than most of us are used to. At the end of the day, though, we still need to physically represent 0's and 1's. Instead of a lightbulb, we could actually use a magnetic particle, which has a north end and a south end. Indeed, this is how data is stored in modern hard drives. Some key take-away points from a video describing how this works: + Hard drives consist of circular platters which spin as data is being written to and read from them. When data is to be stored on the hard drive, it passes from RAM along with software signals that designate how the data is to be stored. Certain signals control how the platters spin and others control the read-write heads. The distance between the heads and platters is less than the width of a human hair, yet the platters spin 5400 RPM or faster. Multiple platters make for greater efficiency than a single platter. + A read-write head in a hard drive contains a tiny electromagnet which conducts the software signals it is passed and, during writing, flips single bits on the platter either on or off by polarizing it in one direction or the opposite. During reading, the process is reversed and the electromagnet conducts signals from the bits on the platter. A single file may be stored in locations scattered widely across a platter, so a separate file keeps track of the locations of all the bits of files. #### ASCII + Now that we have binary to represent numbers, we need a way to represent alphabetic characters. Enter ASCII, an encoding system which represents every alphabetic character with a given number. For example, an uppercase "A" is represented by the number 65 and a lowercase "a" is represented by the number 97. + With this encoding system, we can begin to spell out words. Since individual bits are too small to represent things like words, we'll begin to talk about another standard unit: the byte. A byte is a sequence of 8 bits. If we bring 8 volunteers on stage, we can allow each of them to represent a single bit within a byte. When a volunteer raises her hand, her digit is a 1. Otherwise, her digit is a 0. After four rounds of this, we can represent the numbers 67, 83, 53, and 48, or, according to our ASCII encoding, the characters C, S, 5, and 0. Why use the number 53 instead of the number 5? The number 5 is different from the character "5." ### The Course (35:00-58:00) #### The Unofficial Guide to CS at Harvard and HarvardCourses + Oh, the places you’ll go! Check out the [Unofficial Guide to CS at Harvard](http://guide.cs50.net) for different paths you can take after CS50 and Harvard. + If you haven't already, you can check out [HarvardCourses](http://courses.cs50.net) to explore these courses and others. We've been crunching the numbers to give you a look at how students shop courses at Harvard. Here are some interesting tidbits: + 7.6 is the average number of courses on shopping lists + 201 is the most number of courses on someone's shopping list + For a look at what this path of CS50 and computer science is at Harvard, check out [this clip](http://youtube.com/MrHahvahd) put together by former students and staff. #### Expectations + Here are some simple expectations for you this semester if you decide to take CS50: + attend or watch all lectures and sections + submit eight problem sets + take two quizzes + submit a final project #### Grades + You should feel free to take this class Pass/Fail or for a letter grade. David took it Pass/Fail! #### Lectures + Not to worry, we realize that not all of you will attend lecture in person. That's okay! One of the defining characteristics of CS50 is the innumerable resources available to students, e.g. sections, walkthroughs, office hours, scribe notes (that's me!). We don't see the role of lectures as being to explain all the complex concepts you'll be introduced to this semester. Rather, we intend to bring them to life with memorable moments and examples. + Some of the high-level concepts we'll cover are as follows: + abstraction, algorithms, data structures, encapsulation, resource management, security, software engineering, web development #### Languages + Realize that the programming languages we use in CS50 are largely irrelevant compared to the overarching concepts, but here are a few that you'll learn this semester: + C + PHP + JavaScript + [SQL, CSS, HTML] + You're not learning how to code in this course, you're learning how to solve problems! #### CS50 Appliance + Whether you have a Mac or a PC, you'll be able to use the CS50 Appliance to do all your work for the course. The CS50 Appliance is a virtual machine which allows you to run an operating system (Linux) boxed within your computer's native operating system. #### Problem Sets + Problem Sets come in two editions: standard and Hacker. If you want a little extra challenge out of these projects, try the Hacker Edition. + You have 5 late days that will be provided to you for turning in problem sets after the deadline with no penalty. We understand that life happens and you might not have time for that problem set when a midterm rolls around in another of your courses. Make use of your late days and buy yourself some time. + The lowest score of your problem sets will be dropped, as well, but see the syllabus for fine print. #### Office Hours + Office Hours will be held at Monday through Thursday, 8 p.m. - 11 p.m., in Annenberg Hall. Here you'll have the opportunity to share your struggle through CS50's problems with classmates and to benefit from a substantial support structure. + When you arrive at Office Hours, you'll simply login to [CS50 Discuss](http://cs50.net/discuss) and post your question. The application itself is very much like a typical web discussion forum, but with the additional functionality of escalating questions to staff members. The ultimate goal is to build up a corpus of useful information and common answers to common questions. + When it is determined that your question should be answered live, you'll be dispatched to the CS50 Greeter who, with iPad in hand, will match you to a TF. When this TF becomes available, your computer screen will flash to let you know. #### Sections + Section is an opportunity for more intimate, hands-on problem solving with a single TF and a dozen or so of your classmates. + You'll also have the opportunity to opt in to sharing your work from previous weeks in the class so that you can get direct, dynamic feedback on it. We'll use a new utility called CS50 Spaces to do this. #### Walkthroughs + Once a week, a member of the teaching staff will lead a session that literally walks you through the problem set. He or she will give you hints and starting points for the various problems along the way. Walkthroughs intend to answer the question, "Where do I begin?" + Walkthroughs will be held on Friday to give us as much time as possible to film them and get them online so you can take advantage of them if you don't attend in person. #### Staff + We have 108 members of our teaching staff this year. Wow. + This year we welcome Nate Hardison, our Preceptor, and we welcome back Rob Bowden and Tommy MacWilliam, our Head Teaching Fellows. #### Last Year + A quick run through last year's work: + a game or animation in the graphical programming language known as Scratch + an algorithm to encrypt (or decrypt) passwords + the game of Sudoku! + recovery of data from a formatted photo card + a spellchecker! + a stock-trading website #### CS50 Fair + The course culminates with the CS50 Fair, a chance for you to show off your Final Project to fellow students, staff, and the public! #### CS50 Hackathon + The Hackathon gives you a chance to fulfill the programmer stereotype by staying up all night coding! You'll get to take a shuttle down the street to Microsoft where we'll serve you two dinners and, if you're up for it, breakfast at IHOP at 5 a.m.