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

Discrrete mathematics for computer science random warmup

6 82 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 123,28 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Finding a Short Story• Suppose a book of short stories has both shorter short stories and longer short stories.. • Their order within the book is random.. • You want to pick a random st

Trang 1

Random Warmup

Trang 2

Finding a Short Story

• Suppose a book of short stories has both shorter short stories and longer short stories.

• Their order within the book is

random

• You want to pick a random story to read, but you would prefer it is a

shorter one.

Trang 3

Finding a Short Story

• Two Strategies

– Strategy #1: Flip to a random page, back

up to the beginning of that story, and start reading

– Strategy #2: Flip to a random page, go

forward to the beginning of the next story, and start reading

• (Go to first story if you are at the end of the book)

• Does it matter which strategy you use?

Trang 4

To What Kind of Story Is a Random

Page Likely to Belong

• To be concrete, suppose there are 20 stories

– 10 of them are 10 pages long

– 10 of them are 20 pages lon

• So book is 300 pages long

• The Expected #pages in the story on a

random page is (200∙20+100∙10)/300 =

16.7

• When you pick a random page, it will belong

to a longer story with probability 2/3

Trang 5

The Second Strategy Works Better!

• Strategy #1 will have you reading a

longer story with probability 2/3 and a shorter story with probability 1/3

• Strategy #2 will take you to the

beginning of a random STORY

• So Strategy #2 will take you to the

beginning of a longer story with

probability ½ and a shorter story with probability ½

Trang 6

FINIS

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