Docsity

Discrete Structures Computer Science - Question Paper | CSE 260, Exams of Discrete Structures and Graph Theory

Toggle sidebar
bg1
CSE 260 Exam3, Fall 2008- ANSWER
Time: 40 Minutes
Name:
This exam has 3 pages and 7 problems totaling 90 points. This is closed book and closed
notes. No calculator is allowed in this exam.
1. (5 points) Give the transitive closure of the relation {(1,2),(2,3),(3,2)}defined
over the set {1,2,3}.
{(1,2),(2,3),(3,2),(1,3),(2,2),(3,3)}
2. Following is a relational table containing person names and their telephone
numbers. A person can have more than one telephone number and a telephone
number may belong to more than one person.
PT
name tel
------------------
n1 t1
n2 t1
n2 t2
n3 t3
(a) (5 points) Write the above relational table in set notation.
{(n1, t1),(n2, t1),(n2, t2),(n3, t3)}
(b) Provide a meaning of each of the following queries in simple English. Give
the results of the queries in set notation.
i. (5 point) {y| ∃xP T (x, y )∧x=n2}
Tel numbers of n2.
{t1, t2}
ii. (5 points) {x| ∃yP T (x, y )∧ ∀z(x6=z→ ¬PT (z , y)}
Names of those with tel not shared by anyone else.
{n2, n3}
iii. (5 points) {z| ∃x∃yP T (x, z )∧PT (y , z)∧x6=y}
tel shared by more than one person.
{t1}
iv. (5 points) Give an SQL statement for the query of (b)i.
pf3
pf4

Partial preview of the text

Download Discrete Structures Computer Science - Question Paper | CSE 260 and more Exams Discrete Structures and Graph Theory in PDF only on Docsity!

CSE 260 Exam3, Fall 2008- ANSWER

Time: 40 Minutes

Name:

This exam has 3 pages and 7 problems totaling 90 points. This is closed book and closed notes. No calculator is allowed in this exam.

  1. (5 points) Give the transitive closure of the relation {(1, 2), (2, 3), (3, 2)} defined over the set { 1 , 2 , 3 }. {(1, 2), (2, 3), (3, 2), (1, 3), (2, 2), (3, 3)}
  2. Following is a relational table containing person names and their telephone numbers. A person can have more than one telephone number and a telephone number may belong to more than one person.
PT

name tel

n1 t n2 t n2 t n3 t

(a) (5 points) Write the above relational table in set notation. {(n 1 , t1), (n 2 , t1), (n 2 , t2), (n 3 , t3)} (b) Provide a meaning of each of the following queries in simple English. Give the results of the queries in set notation. i. (5 point) {y | ∃xP T (x, y) ∧ x = n 2 } Tel numbers of n2. {t 1 , t 2 } ii. (5 points) {x | ∃yP T (x, y) ∧ ∀z (x 6 = z → ¬P T (z, y)} Names of those with tel not shared by anyone else. {n 2 , n 3 } iii. (5 points) {z | ∃x∃y P T (x, z) ∧ P T (y, z) ∧ x 6 = y} tel shared by more than one person. {t 1 } iv. (5 points) Give an SQL statement for the query of (b)i.

select x.tel from PT x where x.name=n

  1. Answer the following true/false

(a) (5 points) 001010 0 ∗ 1 ∗ 0 ∗^ false (b) (5 points) Following is a set of valid production rules for a regular grammar: True S → aS S → bS | c

  1. Give the languages, using set builder notation, for the following two grammars.

(a) (5 points) G :< V, T, S, P > V = {S, A, B, a, b, c} T = {a, b, c} P={S → AB, A → aA | c, B → bB | c}

{aicbj^ c | i ≥ 0 ∧ j ≥ 0 } (b) (5 points) G :< V, T, S, P > V = {S, a, b, c} T = {a, b, c} P={S → aSb, S → cS | λ}

{x | x is any combination of a’s and c’s followed by b’s and the number of a’s is equal to number of b’s}

  1. (10 points) Construct a grammar that generates all unsigned integers with no leading 0’s. For example, 123 is valid but 000123 is not valid.

(5 points) Give the parse tree for the word 130.

Grammar: (V, T, S, P ) V = {S, A, D, D′, 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } T = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } P = { S → AD A → 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 D → D′D | λ D′^ → 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 }

{s0} (^) {s0,s1} 1

0 0,

Steps described in class.