Fall22 DS Quiz 2 Solution

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Discrete Structures – Fall-2022 QUIZ-02

Name: Date:

Section: Marks: 30

a. Show that = , ≤, and × are equivalence relation on the set of integers ( Z )

¿ is equivalence relation becauseis reflexive , symmetric∧transitive .


≤ isnot equivalence relation becauseis reflexive , not−symmetric∧transitive .
' ×' is equivalence relation becauseis reflexive , sy mmetric∧transitive .

b. Consider the set f ={( x , y )∈ Z × Z :3 x + y=4 }. Is this a function from Z to Z? Explain.


State domain, codomain, and range of this function. Also state if this function is into
function; or, onto function; or, one-to-one function.

x +3 y=4 means y=( 4−x)/3


Thus f ={... ,(1,1),(4,0) ,(7 ,−1),(10 ,−2), ...}
Therefore , isa function defined for all Z inputs ?
No . f not defined for all domain elements .
For example , f (2) isnot defined .

c. Is the set A={((x , y ) ,(3 y ,2 x , x + y)): x , y ∈ R a function? If so, what is its domain,
codomain and range?

d. Determine, whether the relation R on the set of all people is reflexive, symmetric, and
transitive where ( a , b ) ∈ R if and only if,

i. a is taller than b

Not reflexive: I am not taller than myself.


Not symmetric: X is taller than me, I am not taller than X.
Transitive.

ii. a and b are born on same day


Reflexive, Symmetric, Transitive
iii. a has the same first name as b

Reflexive, Symmetric, Transitive.

iv. a and b have same grandparents.

Relation R would be like: R ( a , b ) =GrandParents ( a ) ∩Grandparents ( b ) ≠ ∅


Discrete Structures – Fall-2022 QUIZ-02
Name: Date:

Section: Marks: 30

Reflexive: GrandParents ( a ) ∩Grandparents ( a ) ≠ ∅


Symmetric: My and my brother's or cousin's grandparents can be same.
Not Transitive: It is not necessary.

e. Determine, whether the relation R on the set of all webpages is reflexive, symmetric, and
transitive where ( a , b ) ∈ R if and only if,

i. Everyone who has visited webpage a, has also visited webpage b

Relation R could be R ( a , b ) ={ x| x visited a}⊆ { x| x visited b }

Reflexive, not-symmetric, transitive

ii. There are no common links found on both webpage a and webpage b

Relation R could be R ( a , b ) =LinksOutof ( a ) ∩ LinksOutof ( b )=∅

Not-Reflexive, Symmetric, not-transitive

iii. There is a webpage that includes links to both webpage a and webpage b

Relation R could be
R ( a , b ) =There∃ a link c such that a ∈ LinksOutof ( c ) , b ∈ LinksOutof ( c )

Not-Reflexive, Symmetric, not-transitive

f. Calculate time complexity for following loops. Draw table and find value of k and range
of k respectively.

 for ¿

This loop will take √ n time

 for (i=n; i ≥ 0;i−¿ 2)

This loop will take ¿1) time.

 for ¿
for (∫ j=n ; j∗j >0 ; j/¿ 2)

Outer Loop: n; Inner Loop :log 2 n+1 ---- Total = n log 2 n


Discrete Structures – Fall-2022 QUIZ-02
Name: Date:

Section: Marks: 30

 for (∫ i=0; i <n ; i+¿ 2)


for ¿

Outer Loop: n/2; Inner Loop :√ i

You might also like