[ppt]cse 20 discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/lect1.pptx · web viewhw1 is...

24
CSE 20 DISCRETE MATH Prof. Shachar Lovett http ://cseweb.ucsd.edu/classes/wi15/cse20-a / iClicker frequency: CA

Upload: vuongdung

Post on 31-Mar-2018

218 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

CSE 20 DISCRETE MATH

Prof. Shachar Lovett

http://cseweb.ucsd.edu/classes/wi15/cse20-a/

iClicker frequency: CA

Page 2: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Learning goals• Mathematics lies at the core of all computer science• It it used to develop fast algorithms that solve complex

problems• This course is the first step

Page 3: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Learning goals

Page 4: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Logistics

http://cseweb.ucsd.edu/classes/wi15/cse20-a/

Page 5: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: grading• Final: 40%

• March 16th

• Midterms (best out of two): 30%• Midterm 1: February 2nd

• Midterm 2: March 2nd

• Homework: 20%

• Online quizzes: 5%

• Class participation (Clicker): 5%

Page 6: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: attendance• This class is interactive – you read the material at home,

we discuss it in class. You need an iClicker. Register it on TED.

• Discussion sections: highly recommended. That is the place to understand the material in a slower pace, see more examples, ask more questions.

• Office hours: highly recommended. This is your one-on-one time to ask questions and make sure you understand everything.

Page 7: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: HW

• Homeworks are in groups of 3-4 students

• Submitted online via TED, by Monday 2pm (before class)

• Collaboration is allowed only within groups, no other collaboration / discussion is allowed

• Need help? Come to discussion sections and office hours

Page 8: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: online quizzes

• Basic questions about definitions from required reading

• Should take no more than 10 mins

• Due before each W/F class

• Online on TED

Page 9: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: Academic integrity• You are working on a homework question with your group

members and are stuck on a question. You run into a friend who solved the problem already and shows you her solution. You look at it, but put it away before continuing the group conversation. Is this cheating?

A. YesB. No

Page 10: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: Academic integrity• You form a group to work on a homework assignment.

There are three group members and three questions. You split up the work so that each student gets one question. After you work on your individual questions for a while, you get together as a group and proofread the solutions, then hand them in. Is this cheating?

A. YesB. No

Page 11: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: Academic integrity• You’re working on a homework question and run across a

definition you don’t understand. You Google the term and, ‘lo and behold, the first hit is a full solution to the homework question. You avoid reading the solution and close the browser. You keep working on the solution and hand in the assignment, without mentioning the Google search since you didn’t use the result. Is this cheating?

A. YesB. No

Page 12: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

About this class: Algorithms!Multiply 17 x 142.

Page 13: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

What did we do?

Page 14: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Is there another way? The RPM Algorithm

Write the factors in two columns.

Repeatedly double the LEFT and halve the right.(Truncate fractions, i.e. toss remainders)

Cross out the LEFT values where the RIGHT values are even.

Add the remaining LEFT values together.

Page 15: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

A needle in a haystack• You’re working in lab and realize your phone is no longer

in your pocket. You turned off the ringer as you came into the room so you know you had it with you. How do you find it?

Page 16: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Cutting a cake

For N=6 how many pieces?

How about for N=600?

Page 17: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Two algorithmsAlg1(real a, pos int n)

x 1.0for i between 1 and n :x x * a

return x

Alg2(real a, pos int n)x 1.0i nwhile i>0 :

if i is odd :x x * a

i i/2if i > 0:

a a * areturn x

Are they correct? Compute the same thing? Which one is better?

Page 18: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Two algorithmsAlg1(real a, pos int n)

x 1.0for i between 1 and n :x x * a

return x

Alg2(real a, pos int n)x 1.0i nwhile i>0 :

if i is odd :x x * a

i i/2if i > 0:

a a * areturn x

Are they correct?

A. Only Alg1 is correctB. Only Alg2 is correctC. Both correctD. Both incorrect

Page 19: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Two algorithmsAlg1(real a, pos int n)

x 1.0for i between 1 and n :x x * a

return x

Alg2(real a, pos int n)x 1.0i nwhile i>0 :

if i is odd :x x * a

i i/2if i > 0:

a a * areturn x

Are they the same algorithm?

A. YesB. No

Page 20: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Two algorithmsAlg1(real a, pos int n)

x 1.0for i between 1 and n :x x * a

return x

Alg2(real a, pos int n)x 1.0i nwhile i>0 :

if i is odd :x x * a

i i/2if i > 0:

a a * areturn x

Do they compute the same function?

A. YesB. No

Page 21: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

Two algorithmsAlg1(real a, pos int n)

x 1.0for i between 1 and n :x x * a

return x

Alg2(real a, pos int n)x 1.0i nwhile i>0 :

if i is odd :x x * a

i i/2if i > 0:

a a * areturn x

Which one is better?

A. Alg1B. Alg2C. Both the sameD. Depends on the inputs

Page 22: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

What’s an algorithm?A. A step by step process B. Any way of solving complex problemsC. Computer codeD. Math

Page 23: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

An algorithm?• Definition: a step-by-step process

• Each basic step is simple• Together they can compute very complicated things

• What properties do we care about?A. It should have the correct format (“compile”)B. It should always terminateC. It should give the correct answerD. All of the above

Page 24: [PPT]CSE 20 Discrete mathcseweb.ucsd.edu/classes/wi15/cse20-a/slides/Lect1.pptx · Web viewHW1 is due Monday Jan 12 5pm Ask any questions you have about the course, expectations,

For next class• Get the book:

Jenkyns, Stephenson and read sections 1.1, 1.2

• HW1 is due Monday Jan 12 5pm

• Ask any questions you have about the course, expectations, requirements either in person or via TED

• Make note of important dates.