cs61a lecture 1 - university of california, berkeley
TRANSCRIPT
![Page 1: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/1.jpg)
CS61A Lecture 1
Amir KamilUC Berkeley
January 23, 2013
![Page 2: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/2.jpg)
Welcome to CS61A!
![Page 3: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/3.jpg)
The Course Staff
I’ve been at Berkeley a long time, and took CS61A a while back. Read the course info to find out when!
TAs essentially run the course
Readers, lab assistants help you learn the material
![Page 4: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/4.jpg)
Some mythical notion of “hacking?”
What is Computer Science?
![Page 5: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/5.jpg)
Some mythical notion of “hacking?”
What is Computer Science?
![Page 6: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/6.jpg)
Some mythical notion of “hacking?”
What is Computer Science?
![Page 7: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/7.jpg)
Some mythical notion of “hacking?”
What is Computer Science?
![Page 8: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/8.jpg)
Some mythical notion of “hacking?”
What is Computer Science?
![Page 9: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/9.jpg)
“Computer science deals with the theoreticalfoundations of information and computation, together with practical techniques for the implementation and application of these foundations”
‐Wikipedia
What is Computer Science?
![Page 10: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/10.jpg)
Computer Science is Everywhere
![Page 11: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/11.jpg)
PhonesCarsPoliticsGamesMoviesMusicSportsAnything connected to the Internet…
Computer Science is Everywhere
![Page 12: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/12.jpg)
PhonesCarsPoliticsGamesMoviesMusicSportsAnything connected to the Internet…
Computer Science is Everywhere
SystemsProgramming LanguagesGraphicsArtificial IntelligenceDatabasesTheorySecurityParallel ComputingQuantum Computing…
![Page 13: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/13.jpg)
An introduction to the “big ideas” in programming Functions, data structures, recursion, interpretation, parallelism, …
We use Python as our programming vehicle in this course, but the ideas apply to any language
General focus: how to manage complexity Primary tool is abstraction
What is CS61A?
![Page 14: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/14.jpg)
What is Abstraction?
![Page 15: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/15.jpg)
Abstraction is exposing the what of something while hiding the how
What is Abstraction?
![Page 16: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/16.jpg)
Abstraction is exposing the what of something while hiding the how
Many layers of abstraction in a typical system
What is Abstraction?
![Page 17: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/17.jpg)
Abstraction is exposing the what of something while hiding the how
Many layers of abstraction in a typical system
What is Abstraction?
Application
Libraries (Graphics, Physics)
Operating System
Hardware (CPU, RAM, etc.)
Logic Gates
![Page 18: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/18.jpg)
Abstraction is exposing the what of something while hiding the how
Many layers of abstraction in a typical system
This course will teach you how to build and use abstractions
What is Abstraction?
Application
Libraries (Graphics, Physics)
Operating System
Hardware (CPU, RAM, etc.)
Logic Gates
![Page 19: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/19.jpg)
The purpose of this course is to help you learn
The staff is here to make you successful
All the details are on the website:http://inst.eecs.berkeley.edu/~cs61a/sp13/about.html
Ask questions on Piazzahttps://piazza.com/class#spring2013/cs61a
Course Policies
![Page 20: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/20.jpg)
Readings cover the material; read before lecture Lectures summarize material, present in new way Labs introduce new topics or practical skills Discussions provide practice on the material Homeworks are deeper exercises that require more thought than labs Graded on effort, generally due Wed. at 11:59pm
Projects are larger assignments designed to teach you how use and combine ideas from the course in interesting ways
Course Organization
![Page 21: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/21.jpg)
Discuss everything with each other EPA: Effort, participation, and altruism Homework may be completed with a partner Projects should be completed with a partner Find a project partner in your section!
The limits of collaboration Never share code Copying projects is a serious offense, and we willfind out if you do
Collaboration
![Page 22: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/22.jpg)
Both lectures are the same; you may attend either, space permitting
Lectures are webcast; link will be online soonMidterms are on 2/13 and 3/21 Final exam is 5/14 for both lectures
Let us know ASAP if you have a conflict with any exam
See the Course Info for enrollment issues If you are on the waitlist, still complete assignments!
FAQ
![Page 23: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/23.jpg)
Make sure you have an account form and register You will need one to submit homework and projects Get one in discussion or office hours if you don’t have one
Office hours start tomorrow See website schedule
Study session Wed. 9:30‐11:30am in the WozMega office hours with multiple staff members present Opportunities for collaboration and EPA
Homework 0 due Fri. at 7pm Homework 1 due Wed. at 11:59pm
Announcements
![Page 24: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/24.jpg)
Data: the things that programs fiddle with
Data, Functions, and Interpreters
![Page 25: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/25.jpg)
Data: the things that programs fiddle with
Data, Functions, and Interpreters
2“Super Bowl XLVII”
Mike KrzyzewskiShakespeare’s 37 plays
![Page 26: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/26.jpg)
Data: the things that programs fiddle with
Functions: rules for manipulating data
Data, Functions, and Interpreters
2“Super Bowl XLVII”
Mike KrzyzewskiShakespeare’s 37 plays
![Page 27: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/27.jpg)
Data: the things that programs fiddle with
Functions: rules for manipulating data
Data, Functions, and Interpreters
2“Super Bowl XLVII”
Mike KrzyzewskiShakespeare’s 37 plays
Add up numbersPronounce someone’s name
Count the words in a line of text
![Page 28: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/28.jpg)
Data: the things that programs fiddle with
Functions: rules for manipulating data
Interpreter: an implementation of the procedure for evaluation
Data, Functions, and Interpreters
2“Super Bowl XLVII”
Mike KrzyzewskiShakespeare’s 37 plays
Add up numbersPronounce someone’s name
Count the words in a line of text
![Page 29: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/29.jpg)
Primitive values are the simplest type of data
Primitive Values and Expressions
![Page 30: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/30.jpg)
Primitive values are the simplest type of dataIntegers: 2, 3, 2013, ‐837592010Floating point (decimal) values: ‐4.5, 98.6Strings: “It was a dark and stormy night”Booleans: True, False
Primitive Values and Expressions
![Page 31: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/31.jpg)
Primitive values are the simplest type of dataIntegers: 2, 3, 2013, ‐837592010Floating point (decimal) values: ‐4.5, 98.6Strings: “It was a dark and stormy night”Booleans: True, False
An expression is something that produces a value
Primitive Values and Expressions
![Page 32: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/32.jpg)
Primitive values are the simplest type of dataIntegers: 2, 3, 2013, ‐837592010Floating point (decimal) values: ‐4.5, 98.6Strings: “It was a dark and stormy night”Booleans: True, False
An expression is something that produces a value2 + 3sqrt(2401)abs(‐128 + 42 * 3)
Primitive Values and Expressions
![Page 33: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/33.jpg)
All expressions can use function call notation
Call Expressions in Python
![Page 34: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/34.jpg)
All expressions can use function call notation2 + 3 add(2, 3)sqrt(2401) sqrt(2401)abs(‐128 + 42 * 3) abs(add(‐128, mul(42, 3)))
Call Expressions in Python
![Page 35: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/35.jpg)
All expressions can use function call notation2 + 3 add(2, 3)sqrt(2401) sqrt(2401)abs(‐128 + 42 * 3) abs(add(‐128, mul(42, 3)))
Infix operator notation is syntactic sugar for function calls
Call Expressions in Python
![Page 36: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/36.jpg)
All expressions can use function call notation2 + 3 add(2, 3)sqrt(2401) sqrt(2401)abs(‐128 + 42 * 3) abs(add(‐128, mul(42, 3)))
Infix operator notation is syntactic sugar for function calls
Mathematical operators obey usual precedence rules
Call Expressions in Python
![Page 37: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/37.jpg)
Anatomy of a Call Expression
add ( 2 , 3 )Operator Operand 0 Operand 1
![Page 38: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/38.jpg)
Operators and operands are expressions, so they evaluate to values
Anatomy of a Call Expression
add ( 2 , 3 )Operator Operand 0 Operand 1
![Page 39: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/39.jpg)
Operators and operands are expressions, so they evaluate to values
Evaluation procedure for call expressions:
Anatomy of a Call Expression
add ( 2 , 3 )Operator Operand 0 Operand 1
![Page 40: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/40.jpg)
Operators and operands are expressions, so they evaluate to values
Evaluation procedure for call expressions:1. Evaluate the operator and operand subexpressions in order
from left to right.
Anatomy of a Call Expression
add ( 2 , 3 )Operator Operand 0 Operand 1
![Page 41: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/41.jpg)
Operators and operands are expressions, so they evaluate to values
Evaluation procedure for call expressions:1. Evaluate the operator and operand subexpressions in order
from left to right.2. Apply the function that is the value of the operator
subexpression to the arguments that are the values of the operand subexpressions
Anatomy of a Call Expression
add ( 2 , 3 )Operator Operand 0 Operand 1
![Page 42: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/42.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
![Page 43: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/43.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
mul
![Page 44: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/44.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )mul
![Page 45: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/45.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )mul
add
![Page 46: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/46.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )mul
add 2
![Page 47: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/47.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )mul
add 2mul ( 4 , 6 )
![Page 48: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/48.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )mul
add 2mul ( 4 , 6 )
mul 4 6
![Page 49: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/49.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )mul
add 2mul ( 4 , 6 )
mul 4 6
24
![Page 50: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/50.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )26mul
add 2mul ( 4 , 6 )
mul 4 6
24
![Page 51: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/51.jpg)
Evaluating Nested Expressions
mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )26mul
add 2mul ( 4 , 6 )
mul 4 6
24
add ( 3 , 5 )
add 3 5
8
![Page 52: CS61A Lecture 1 - University of California, Berkeley](https://reader033.vdocument.in/reader033/viewer/2022060902/62989a71a8ef6c670d735093/html5/thumbnails/52.jpg)
Evaluating Nested Expressions
208mul ( add(2, mul(4, 6)) , add(3, 5) )
add ( 2 , mul(4, 6) )26mul
add 2mul ( 4 , 6 )
mul 4 6
24
add ( 3 , 5 )
add 3 5
8