15.04.2015 Views

Lectures

Lectures

Lectures

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This is CS 50.<br />

Harvard College’s Introduction to Computer Science I<br />

COMPUTER<br />

z<br />

SCIENCE 50<br />

WEEK 0<br />

DAVID J. MALAN ’99<br />

malan@post.harvard.edu<br />

2


Divide and Conquer<br />

z<br />

h"p://www.youtube.com/watch?v=P4fcOLN9heU<br />

3


Lolcats<br />

z<br />

h"p://www.youtube.com/watch?v=3jDfSqtG2E4<br />

4


Roll Call<br />

1. Stand up.<br />

2. Think to yourself: “I am #1.”<br />

3. Pair off with someone standing, add your<br />

numbers together, and adopt the sum as your<br />

new number.<br />

4. One of you should sit down, z the other should go<br />

back to step 3.<br />

5


“Does everyone know more than me?”<br />

z<br />

6


Prior Coursework in CS<br />

z<br />

7


Gender Ratio<br />

Fall 2007 Fall 2008<br />

female<br />

29%<br />

female<br />

38%<br />

z<br />

male<br />

71%<br />

male<br />

62%<br />

8


20th Anniversary Edition<br />

9


Binary<br />

z<br />

13


Binary<br />

z<br />

14


Binary<br />

128s 64s 32s 16s 8s 4s 2s 1s<br />

z<br />

15


Binary<br />

128s 64s 32s 16s 8s 4s 2s 1s<br />

z<br />

15


Binary<br />

128s 64s 32s 16s 8s 4s 2s 1s<br />

z<br />

15


Binary<br />

128s 64s 32s 16s 8s 4s 2s 1s<br />

z<br />

15


Binary<br />

128s 64s 32s 16s 8s 4s 2s 1s<br />

z<br />

15


Binary<br />

128s 64s 32s 16s 8s 4s 2s 1s<br />

z<br />

15


ASCII<br />

z<br />

16


Geek Humor<br />

z<br />

17


<strong>Lectures</strong><br />

Week 0<br />

Introduction. Bits. Binary. ASCII.<br />

Programming. Algorithms. Scratch.<br />

Statements. Boolean expressions. Conditions.<br />

Loops. Variables. Threads. Events.<br />

z<br />

18


<strong>Lectures</strong><br />

Week 1<br />

Functions, continued. Global variables.<br />

Parameters. Return Values. Stack. Frames.<br />

Scope. Arrays. Strings. Command-line<br />

arguments. Cryptography.<br />

z<br />

19


<strong>Lectures</strong><br />

Week 3<br />

Linear search. Binary search. Asymptotic<br />

notation. Recursion. Pseudorandomness.<br />

Bubble sort. Selection sort. Insertion sort.<br />

Merge sort. Debugging.<br />

z<br />

20


<strong>Lectures</strong><br />

Week 4<br />

Structures. Dynamic memory allocation. Stack<br />

and heap. Pointers. Debugging, continued.<br />

z<br />

21


<strong>Lectures</strong><br />

Week 5<br />

File I/O. Forensics. Linked lists. Stacks.<br />

Queues.<br />

z<br />

22


<strong>Lectures</strong><br />

Week 7<br />

Valgrind. Bitwise operators. Hash tables.<br />

Trees. Binary search trees. Tries. Heaps.<br />

Heapsort. Huffman coding.<br />

z<br />

23


<strong>Lectures</strong><br />

Week 8<br />

TCP/IP. HTTP. XHTML. PHP. SQL.<br />

z<br />

24


<strong>Lectures</strong><br />

Week 9<br />

DOM. CSS. Inheritance. JavaScript. Events,<br />

continued. OOP. Ajax.<br />

z<br />

25


<strong>Lectures</strong><br />

Week 10<br />

Preprocessing. Compiling. Assembling.<br />

Linking. CPUs.<br />

z<br />

26


Expectations<br />

‣ Attend all lectures and sections.<br />

‣ Complete nine problem sets.<br />

‣ Take two quizzes.<br />

‣ Produce a final project.<br />

‣ (No final exam.)<br />

z<br />

27


Grades<br />

‣ Problem Sets (best 8 out of 9): 60%<br />

‣ Quizzes: 30%<br />

‣ Final Project: 10%<br />

You may take the course pass/fail.<br />

z<br />

28


Website<br />

http://www.cs50.net/<br />

‣ Bulletin Board<br />

‣ Grades<br />

‣ Handouts<br />

‣ Resources<br />

‣ Software<br />

‣ Videos<br />

z<br />

‣ Virtual Terminal Room<br />

‣ ...<br />

29


Books<br />

None are required!<br />

‣ Absolute Beginner’s Guide to C<br />

‣ Programming in C<br />

‣ How Computers Work<br />

‣ Hacker’s Delight<br />

z<br />

30


<strong>Lectures</strong><br />

‣ MW 1 - 2:30pm.<br />

‣ Plus this F and next F.<br />

z<br />

31


Sections<br />

Online sectioning begins Wed 9/9!<br />

‣ For “those less comfortable.”<br />

‣ For “those more comfortable.”<br />

‣ For those somewhere in between.<br />

z<br />

32


Staff<br />

‣ Teaching Fellows<br />

‣ Course Assistants<br />

‣ Sysadmins<br />

‣ AV, Producers, Videographers<br />

‣ Scribes<br />

‣ me<br />

z<br />

33


Office Hours<br />

Start next week!<br />

34


Virtual Office Hours<br />

Start in two weeks!<br />

z<br />

35


Workload<br />

z<br />

36


Algorithms<br />

1 let socks_on_feet = 0<br />

2 while socks_on_feet != 2<br />

3 open sock drawer<br />

4 look for sock<br />

5 if you find a sock then<br />

6 put on sock<br />

7 socks_on_feet++<br />

8 look for matching sock<br />

9 if you find a matching sock z then<br />

10 put on matching sock<br />

11 socks_on_feet++<br />

12 close sock drawer<br />

13 else<br />

14 remove first sock from foot<br />

15 socks_on_feet--<br />

16 else<br />

17 do laundry and replenish sock drawer<br />

49


O hai, C!<br />

hai.c<br />

#include <br />

int<br />

main(int argc, char *argv[])<br />

{<br />

printf("O hai, world!\n"); z<br />

}<br />

50


O Hai, C!<br />

#include <br />

int<br />

main(int argc, char *argv[])<br />

{<br />

}<br />

printf("O hai, world!\n");<br />

10000011 00000001 00010001 00000000 00111101 11111100 01110100 00111101<br />

00000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000<br />

10010000 00000000 00000000 00000000 01010000 00000000 00000111 00110000<br />

00001011 00000001 00001011<br />

z<br />

00000011 00001010 00000000 00000000 00000000<br />

00000000 00100000 00000000 00000000 00000000 00000000 00000000 00000000<br />

00000000 00100000 00000000 00000000 00000000 00000000 00000000 00000000<br />

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br />

01110000 00010000 00000000 00100000 00000001 00000000 00000000 00000000<br />

00000000 00000000 00000000 00100000 00000001 00000000 00000000 00000000<br />

00000000 00000000 00000000 01000000 00000001 00000000 00000000 00000000<br />

00000000 00100000 00000000 01000000 00000001 00000000 00000000 00000000<br />

11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111<br />

10010000 10000000 00000000 01000000 00000001 00000000 00000000 00000000<br />

00101110 01100100 01111001 01101110 01100001 01101101 01101001 01100011<br />

10110000 00000100 00000000 00100000 00000001 00000000 00000000 00000000<br />

10110000 00000100 00000000 00100000 00000001 00000000 00000000 00000000<br />

10100000 00000001 00000000 00000000 00000000 00000000 00000000 00000000<br />

10110000 00000100 00000000 00000000 00000000 00000000 00000000 00000000<br />

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br />

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br />

00000000 00000000 00000000 00000000 00000000 00100000 00000000 00000000<br />

[...]<br />

51


O hai, Scratch!<br />

Hai1.sb<br />

z<br />

52


Statements<br />

z<br />

...<br />

53


Statements<br />

Hai{2,3}.sb<br />

z<br />

54


Boolean Expressions<br />

z<br />

...<br />

55


Conditions<br />

...<br />

z<br />

56


Conditions<br />

Hai{4,5}.sb<br />

z<br />

57


Loops<br />

z<br />

58


Loops<br />

Hai{6,7,8}.sb<br />

z<br />

59


Variables<br />

Count{1,2}.sb<br />

z<br />

60


Arrays<br />

z<br />

61


Arrays<br />

FruitcraftRPG.sb<br />

z<br />

62


Threads<br />

Move1.sb<br />

z<br />

63


Threads<br />

Move2.sb<br />

z<br />

64


Threads<br />

Hai10.sb<br />

z<br />

65


Threads<br />

David.sb<br />

z<br />

66


Events<br />

Marco.sb<br />

z<br />

67


Sensors<br />

singer.sb, Masquerade.sb, davidwu.sb<br />

z<br />

68


Oscartime<br />

Oscartime.sb<br />

z<br />

69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!