Neal Whittington (whittin3) Tuesdays, at 4:00PM AD9
CS 173: Discrete Structures, Spring 2010
Homework 4
This homework contains 5 problems worth a total of 50 points. It is due on Friday, 19
February at 4pm.
1.
Set Operations [16 points]
Suppose you were given the following sets:
A
=
{
Piano
,
{
Violin
,
Viola
,
Cello
}
,
Guitar
}
B
=
{{
Flute, Piccolo
}
,
Cymbals
}
C
=
{
Piano
,
Flute
}
D
=
{{
Violin, Viola, Cello
}
,
{
Flute, Piccolo
}}
List the elements of the set for the following expressions:
(a)
A
∪
D
{
Piano
,
{
Violin
,
Viola
,
Cello
}
,
Guitar
,
{
Flute, Piccolo
}}
(b)
B
∩
C
∅
(c)
A

(
B

C
)
{
Piano,
{
Violin, Viola, Cello
}}
(d)
A
∩
P
(
B
∩
C
)
∅
(e) (
B
∩
D
)
×
C
{{
Flute, Piccolo
} × {
Piano, Flute
}
=
{{
Flute, Piano
}
,
{
Flute, Flute
}
,
{
Piccolo, Piano
}
,
{
Piccolo, Flute
}}
(f)

P
(
B
∩
D
)

{{
Flute
}
,
{
Piccolo
}
,
{ ∅ }
,
{
Flute, Piccolo
}}
(g)
{
X
∈
P
(
A
) :

X

is not prime
}
(h)
{
X
∈
(
P
(
A
)
∪
P
(
B
)) :

X
 ≡
3
(mod 2)
}
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2.
Euclidean algorithm [4 points]
x
y
r
837
2013
837
2013
837
341
341
155
31
155
31
0
31
0
gcd
(837
,
2015) is 31.
3.
Pseudocode [10 points]
(a) Trace the execution of
func(a, b)
.
a
b
m
p
return
2
5
func(2, 2)
= 4
func(2, 1)
= 2
32
2
2
func(2, 1)
= 2
func(2, 0)
= 1
4
2
1
2
2
0
1
32 = 2
5
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 Erickson
 Euclidean algorithm, equivalence class, Euclidean domain

Click to edit the document details