28
CSE 312 Foundations of Computing II Lecture 1: Welcome & Introduction Stefano Tessaro [email protected] 1

CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

CSE 312

Foundations of Computing IILecture 1: Welcome & Introduction

Stefano Tessaro

[email protected]

1

Page 2: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

2

Foundations of Computing II

=

Introduction to Probability & Statisticsfor computer scientists

What is probability?? Why probability?!

Page 3: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

3

Probability

Big data

Data compression

Congestion

control

Cryptography

Load Balancing

Machine Learning

Data Structures

Natural Language

Processing

Algorithms

Computational

Biology

Fault-tolerant

systems

Complexity theory

Error-correcting

codes

+ much more!

Page 4: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

CSE 312 team

4

Kushal JhunjhunwallaLeonid Baraznenok

barazl@cs kushaljh@csDuowen (Justin) Chen

chendw98@cs

Tina Kelly Li

3nakli@csZhanhao Zhang

zhangz73@csSu Ye

yes23@csSiva N. Ramamoorthy

sivanr@cs

Stefano Tessaro

tessaro@cs

Cryptographer, Associate Professor @ Allen School since Jan 2019.

Page 5: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Most important info

https://courses.cs.washington.edu/courses/cse312/19au/

5

tl;dr:

• Weekly Homework, starting next week, Wed – Wed schedule. Submissions via Gradescope only, individual submissions.

• Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them.

• Office hours on M/T/W.• Midterm on Friday 11/1. • Grade (approx.): 50% HW, 15% midterm, 35% final• Panopto is activated – not a replacement for class attendance!

Page 6: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Class materials + textbook

Mandatory textbook: Dimitri P. Bertsekas and John N. Tsitsiklis, Introduction to Probability, First Edition, Athena Scientific, 2000. [Available for free!]

Optional: Kenneth H. Rosen, Discrete Mathematics and Its Applications, McGraw-Hill, 2012.

I will use slides. These will be available online.

6

Page 7: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Review: Sets and Sequences

7

Page 8: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Sets

“Definition.” A set is a collection of (distinct) elements from a universe Ω.

8

Notation:• " ∈ $: " belongs to / is an element of $• " ∉ $: " does not belong to / is not an element of $• |$|: size / cardinality of $

Order irrelevant: 1,2,3 = 3,1,2 = 3,2,1 = 1,3,2 = ⋯No repe00ons: 1,2,2,3 = 1,2,3

Page 9: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Subsets / set inclusion

9

-

.Defini&on. - ⊆ . if ∀": " ∈ - ⇒ " ∈ .

Examples:

• 1,2,3 ⊆ {1,2,3,5}• 1,2,3 ⊆ {1,2,3}• 1,2,3 ⊈ {1,2,4}

Defini&on. - ⊂ . if - ⊆ . ∧ - ≠ .

Examples:

• 1,2,3 ⊂ {1,2,3,5}• 1,2,3 ⊄ {1,2,3}• 1,2,3 ⊄ {1,2,4}

Page 10: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Common sets

10

• Empty set: ∅

• First = integers: [=] = {1,2, … , =}

• Integers: ℤ = {… ,−3,−2,−1,0,1,2,3, … }

• Naturals: ℕ = {0,1,2,3, … }

• Reals: ℝ (aka. points on the real line)

• Ra&onals: ℚ = GH∈ ℝ I, J ∈ ℤ, J ≠ 0}

finite sets

infinite sets

countable

uncountable

Page 11: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Implicit descriptions

11

Often, sets are described implicitly.

What is this set?

$K = {I ∈ ℕ | 1 ≤ I ≤ 7}

$K = {1,2,3,4,5,6,7}

What is this set?

$O = I ∈ ℕ ∃Q ∈ ℕ: I = 2Q + 1}

$O = 1,3,5,7, … = the odd naturals

unambiguous

ambiguous

Page 12: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Set operations

12

- ∪ . = " | " ∈ - ∨ " ∈ .-

.

- ∩ . = " | " ∈ - ∧ " ∈ .-

.

- ∖ . = " | " ∈ - ∧ " ∉ .-

.

set union

set intersection

set difference

[Sometimes also: - − .]

Page 13: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Set operations (cont’d)

13

-W = " | " ∉ - = Ω ∖ --

set complementuniverse Ω

Fact 1. -W W = -.

[Sometimes also: -̅]

Fact 2. - ∪ . W = -W ∩ .W.

Fact 3. - ∩ . W = -W ∪ .W.“De Morgan’s Laws”

Page 14: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Sequences

14

A (finite) sequence (or tuple) is an (ordered) list of elements.

Definition. The cartesian product of two sets $, Y is

$×Y = { I, J : I ∈ $, J ∈ Y}

Equivalent naming: 2-sequence = 2-tuple = ordered pair.

Order ma9ers: 1,2,3 ≠ 3,2,1 ≠ (1,3,2)Repe00ons ma9er: 1,2,3 ≠ 1,2,2,3 ≠ 1,1,2,3

Page 15: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Cartesian product – cont’d

15

Definition. The cartesian product of two sets $, Y is

$×Y = { I, J : I ∈ $, J ∈ Y}

Example.

1,2,3 × ★, ♠ = { 1,★ , 2,★ , 3,★ , 1, ♠ , 2, ♠ , 3, ♠ }

Page 16: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Cartesian product – even more notation

$×Y×^ = { I, J, _ : I ∈ $, J ∈ Y, _ ∈ ^}

16

$×Y×^×`… Notation. $a = $×$×⋯×$

Q times

Page 17: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Next – Counting (aka ”combinatorics”)

17

Page 18: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

We are interested in counting the number of objects with a certain given property. [Weeks 0-1]

18

“How many ways are there to assign 7 TAs to 5 sec3ons, such that each sec3on is assigned to two TAs, and no TA is assigned to more than two sec3ons?”

“How many integer solutions ", b, c ∈ ℤd does the equation "d + bd = cd have?”

Generally: Question boils down to computing cardinality |$| of some given (implicitly defined) set $.

Page 19: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Example – Strings

How many string of length 5 over the alphabet -, ., e, … , f are there?• E.g., AZURE, BINGO, TANGO, STEVE, SARAH, …

19Answer: 26g = 11881376

String =

- .

26 op&ons

h f

- . f

- . fi

- . fj

- . fk

h - i j k

26 options

26 op&ons

26 op&ons

26 op&ons

Page 20: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Product rule – Generally

20

-K×-O×⋯×-l = -K × -O ×⋯×|-l|

Page 21: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Example – Strings

How many string of length 5 over the alphabet -, ., e, … , f are there?• E.g., AZURE, BINGO, TANGO, STEVE, SARAH, …

-, ., e, … , f g = -, ., e, … , f g = 26g.

21

Product rule

Page 22: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Example – Laptop customization

Alice wants to buy a new laptop: • The laptop can be blue, orange, purple, or silver.• The SSD storage can be 128GB, 256GB, and 512GB

• The available RAM can be 8GB or 16GB.• The laptop comes with a 13” or with a 15” screen.

How many different laptop configurations are there?

22

Page 23: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Example – Laptop customization (cont’d)

23

e = {blue, orange, purple, silver}n = {128GB, 256GB, 512GB}o = {8GB, 16GB}$ = {13”, 15”}

Configuration = element of e×n×o×$

# configurations = e×n×o×$

= e × n × o × $

= 4×3×2×2 = 48.Product rule

Page 24: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Example – Power set

24

Definition. The power set of $ is

2r = {s | s ⊆ $} .

Proposition. |2r| = 2|r|.

Example. 2 ★,♠ = {∅, ★ , ♠ , {★, ♠}}2∅ = {∅}…

Page 25: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Proof of proposition

25

subset s ⊆ $ sequence 1t ∈ 0,1 l

1t = ("K, … , "l) where "u = v1 if yu ∈ s0 if yu ∉ s

Proposition. |2r| = 2|r|.

Let $ = {yK, … , yl} (i.e., $ = = ≥ 1)

1-to-1 correspondence

Therefore: |2r| = | 0,1 l|= 0,1 l

Product rule

= 2l

(Case $ = ∅ needs to be handled separately)

Page 26: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

26

Sequential process: We fix elements in a sequence one by one, and see how many possibilities we have at each step.Example: “How many sequences are there in 1,2,3 d?”

1

2

3

1

1 1 1

1 1

1 1 1 1 1 1

2

2 2 2 2 2 2 2 2 2

3 3 32 2

333333333

"K

"O

"d

27 paths = 27 sequences

Page 27: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

27

Example: “How many sequences are there in 1,2,3 d with no repea3ng elements?”

1

2

3

1 1

1 1

2

2 2

3 3 2

33

"K

"O

"d

6 sequences

Page 28: CSE 312 Foundations of Computing II · 2019. 12. 10. · •Weekly Quiz Sessions, starting tomorrow. Short review + in-class assignment, posted one day in advance. Do attend them

Factorial

28

“How many sequences in = l with no repea3ng elements?”

Answer = =× = − 1 × = − 2 ×⋯×2×1

”Permutations”

Definition. The factorial function is

=! = =× = − 1 ×⋯×2×1 .

Theorem. (Stirling’s approximation)

2| ⋅ =l~KO ⋅ �Äl≤ =! ≤ � ⋅ =l~

KO⋅ �Äl .

= 2.5066 = 2.7183