comp 382 unit 1 questions swarat chaudhuri & john greiner

15
COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

Upload: cathleen-campbell

Post on 18-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

COMP 382Unit 1 Questions

Swarat Chaudhuri & John Greiner

Page 2: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

What do you need to do after class?

A. Do first assignmentB. Take first quizC. Sign up for tutorial sectionD. Read 10 chapters of textbook

Do first assi

gnm

ent

Take

first quiz

Sign up fo

r tuto

rial s

ection

Read 10

chap

ters

of textb

ook

0% 0%0%0%

Response

Counter

Page 3: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

List definition has how many cases?

A. 1B. 2C. 3D. 4

1 2 3 4

0% 0%0%0%

Response

Counter

Page 4: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

function append (x: List, y: List): List { match x case Empty => ??? case Cons(m, z) => ???}

How to complete base case?

A.xB.yC.Empty

x y

Empty

0%0%0%

Response

Counter

Page 5: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

function append (x: List, y: List): List { match x case Empty => y case Cons(m, z) => ???}

How to complete inductive case?

A.Cons(m, append(x, z))B.Cons(m, append(z, x))C.Cons(m, append(y, z))D.Cons(m, append(z, y))

Cons(m, a

ppend(x,

z))

Cons(m, a

ppend(z,

x))

Cons(m, a

ppend(y,

z))

Cons(m, a

ppend(z,

y))

0% 0%0%0%

Response

Counter

Page 6: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

function reverse (x: List): List { match x case Empty => Empty case Cons(m, z) => ???}

How to complete inductive case?

A.Cons(z, m)B.append(z, m)C.append(reverse(z), m)D.append(reverse(z), Cons(m, Empty))

Cons(z, m

)

appen

d(z, m

)

appen

d(reve

rse(z)

, m)

appen

d(reve

rse(z)

, Cons(m

, Em

...

2%

46%50%

3%

Page 7: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

To prove: is divisible by , for .

How many cases in inductive proof?

A. 1B. 2C. 3D. 4

1%

65%

2%1%1%

7%

24%

Page 8: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

To prove: is divisible by , for .

What is the inductive case?

A. If , then .B. If , then .

0%0%

Response

Counter

Page 9: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

To prove: , for .

What is base case?

$$=0

$$=1

$$=2

0%0%0%

Response

Counter

Page 10: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

< is a well-founded relation over ℕ.

A. TrueB. False

True

False

0%0%

Response

Counter

Page 11: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

is a well-founded relation over ℕ.

A. TrueB. False

True

False

0%0%

Response

Counter

Page 12: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

< is a well-founded relation over ℤ.

A. TrueB. False

True

False

0%0%

Response

Counter

Page 13: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

Which is a well-founded relation on ℕ×ℕ?

iff …

$$<$$

$$<$$

and $$<$$

$$<$$

or $$<

$$

$$<$$

or $$

=$$ an

d $$<$$

$$+$$

<$$+$

$

0% 0%0%0%0%

Response

Counter

Page 14: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

For chips puzzle, do induction on what?Remove a red and anything → Put in none.Remove two yellow → Put in 1 yellow, 5 blue.Remove a blue and not red → Put in 10 red.

A. Total # of chipsB. Lex. order (#red, #yellow, #blue)C. Lex. order (#blue, #yellow, #red)D. Lex. order (#yellow, #blue, #red)

Total

# of chips

Lex.

order

(#red, #

yello

w, #blue)

Lex.

order

(#blue,

#yello

w, #re

d)

Lex.

order

(#yello

w, #blue,

#red

)

0% 0%0%0%

Response

Counter

Page 15: COMP 382 Unit 1 Questions Swarat Chaudhuri & John Greiner

Induction guarantees what for inductively-defined programs?A. TerminationB. CorrectnessC. Most efficient algorithmD. No such general statement

always holds

Term

ination

Correctn

ess

Most

efficie

nt algo

rithm

No such

gener

al sta

temen

t alw

...

0% 0%0%0%

Response

Counter