comp 382 unit 1 questions swarat chaudhuri & john greiner
TRANSCRIPT
COMP 382Unit 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
List definition has how many cases?
A. 1B. 2C. 3D. 4
1 2 3 4
0% 0%0%0%
Response
Counter
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
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
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%
To prove: is divisible by , for .
How many cases in inductive proof?
A. 1B. 2C. 3D. 4
1%
65%
2%1%1%
7%
24%
To prove: is divisible by , for .
What is the inductive case?
A. If , then .B. If , then .
0%0%
Response
Counter
To prove: , for .
What is base case?
$$=0
$$=1
$$=2
0%0%0%
Response
Counter
< is a well-founded relation over ℕ.
A. TrueB. False
True
False
0%0%
Response
Counter
is a well-founded relation over ℕ.
A. TrueB. False
True
False
0%0%
Response
Counter
< is a well-founded relation over ℤ.
A. TrueB. False
True
False
0%0%
Response
Counter
Which is a well-founded relation on ℕ×ℕ?
iff …
$$<$$
$$<$$
and $$<$$
$$<$$
or $$<
$$
$$<$$
or $$
=$$ an
d $$<$$
$$+$$
<$$+$
$
0% 0%0%0%0%
Response
Counter
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
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