1. Trang chủ
  2. » Giáo án - Bài giảng

Discrrete mathematics for computer science counting

19 33 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 19
Dung lượng 193,8 KB

Nội dung

Counting First Principles 3/22/19 Counting in Gambling What fraction of poker hands are “a pair of Jacks?” (probability of a pair of Jacks) 3/22/19 Counting in Algorithms # ops to update a data structure (# comparisons needed to sort n items) # steps in a computation (# n multiplies to compute d ) 3/22/19 Counting in Cryptography # possible passwords # possible keys 3/22/19 lec 10W.4 Sum Rule A B If sets A and B are disjoint, then |A ∪ B| = |A| + |B| 3/22/19 The Sum Rule • Class has 17 women, 25 men so total enrollment = 17 + 25 = 42 • 26 lower case letters, 26 upper case letters, and 10 digits, so # characters = 26+26+10 = 62 3/22/19 lec 10W.6 The Product Rule If there are men and women, there are 4⋅3 = 12 different man/woman couples 3/22/19 Product Rule If |A| = m and |B| = n, then |A × B| = m⋅n A = {a, b, c, d}, B = {1, 2, 3} A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3), (c,1),(c,2),(c,3), (d,1),(d,2),(d,3) } 3/22/19 Product Rule: Counting Strings # length-4 binary strings = |B × B × B × B| = |B | where B ::= {0,1} =2·2·2·2=2 3/22/19 Product Rule: Counting Strings # length n strings from an alphabet of size m is m 3/22/19 n 10 Example: Counting Passwords Password conditions: • • • • 3/22/19 characters are digits & letters between & characters long starts with a letter case sensitive 11 Counting Passwords L ::= {a,b,…,z,A,B,…,Z} D ::= {0,1,……,9} Pn ::= length n words starting w/letter = L × (L ∪ D) 3/22/19 n-1 12 Counting Passwords |L × (L ∪ D) n-1 = |L|·|(L ∪ D)| | n-1 = |L|·(|L| + |D|) = 52·(52+10) 3/22/19 n-1 n-1 13 Counting Passwords set of passwords: P ::= P6∪ P7∪P8 |P| = |P6|+|P7|+|P8| = 52·(62 +62 +62 ) 14 ≈ 19·10 3/22/19 14 # 4-digit nums w/ ≥ one cases by 1st occurrence of 7: x: any digit o: any digit ≠ 7xxx or o7xx or oo7x or ooo7 • 103 + 9·10 3/22/19 = 3439 + ·10 + 15 at least one 7: another way |4-digit nums w/ ≥ one 7| = |4-digit nums| − |those w/ no 7| = 3/22/19 104 − 94 = 3439 16 Cracking Passwords by Exhaustive Search • Suppose a password has to be a string of letters and digits beginning with a letter • • So there are 52∙62n-1 passwords of length n • How big does n have to be for it to take more than a day to try them all? Suppose a computer can try a password every billionth of a second (one nanosecond per try) 3/22/19 17 More than a day: • • • • n-1 52∙62 > number of nanoseconds in a day = 24∙60∙60∙10 n-1 12 62 > 1.66∙10 n-1 > log (1.66∙10 12 )/log 62 ≈ 6.8 So if passwords are at least characters long it would take more than a day to try them all by exhaustive search 3/22/19 18 FINIS 3/22/19 19 .. .Counting in Gambling What fraction of poker hands are “a pair of Jacks?” (probability of a pair of Jacks) 3/22/19 Counting in Algorithms # ops to update... (d,1),(d,2),(d,3) } 3/22/19 Product Rule: Counting Strings # length-4 binary strings = |B × B × B × B| = |B | where B ::= {0,1} =2·2·2·2=2 3/22/19 Product Rule: Counting Strings # length n strings... 3/22/19 n 10 Example: Counting Passwords Password conditions: • • • • 3/22/19 characters are digits & letters between & characters long starts with a letter case sensitive 11 Counting Passwords

Ngày đăng: 22/03/2019, 11:22