1 / 3

Key Answers for Homework #1

3 . (1) Base: When there is one node. To have a path, there should be an edge, which is self-loop as shown below. Obviously, a path of length greater than or equal to one has a cycle. 1. 1. 1. 2. 1. 1. 2. Figure (a) Odd case. Figure (b) Even case. Key Answers for Homework #1.

lewis
Download Presentation

Key Answers for Homework #1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3. (1) Base: When there is one node. To have a path, there should be an edge, which is self-loop as shown below. Obviously, a path of length greater than or equal to one has a cycle. 1 1 1 2 1 1 2 Figure (a) Odd case Figure (b) Even case Key Answers for Homework #1 1. (a) { aibjck | i, j, k  0 } (b) { aibjck | i, j, k > 0, ij and jk } (c) { aibjai | i, j  0 } (d) { aibicj | i, j  0 } (e) { aibjckalbman | i, j, k > 0, jk, and l, m, n  0 } 2. The number of bad label blocks can be either odd or even as shown below; (2) Induction hypothesis: Suppose that on every directed graph G of n’ nodes such that n’ < n, every path of length greater than or equal to n’ has a cycle.

  2. Fig. (c). Fig. (a) Fig. (b) Fig. (d) (3) Induction: We prove that on any directed graph G of n’+1 nodes, every path of length greater than or equal to n’+1 has a cycle. We study the problem according to the following 4 cases: (a) There is a node such that none of its (incoming or outgoing) edges are in the path (see Fig. (a)). Delete this node and its edges, and let the resulting graph be G’. Then G’ has n’ nodes and the path length is greater than or equal to n’+1. According to the induction hypothesis, the path has a cycle. (b)There is a node on which the path either ends or starts (see Fig. (b) and (c)). As for case (a), delete such node and its (outgoing and incoming) edges, and let the resulting graph be G’. Then G’ has n’ nodes and the path length is greater than or equal to n’. Again according to the induction hypothesis, the path has a cycle. (c ) The path goes through every node (see Fig. (d)). This implies a cycle because the start node is visited again.

  3. (a) {a, b}*(b){xxR | x  {a, b}+}(c) {aibj | i > j  0} (d) { a2ibici | i  1 } • 5. (a) S  ab | abb | abbb (b) S  0S | 1S | 0 | 1 (c) S 0S | 1S | 2S . . . . | 9S | 0 | 1 | 2 . . . | 9 • 6. (a) S  aSb | aAb A  aA | a(b) S  aSb | aBb B  Bb | b • (c) S  S1 | S2 S1 aS1b | aAb A  aA | a S2 aS2b | aBb B  Bb | b • ** Notice that S1 and S2 are nonterminal symbols. Using these symbols we are generating both languages • generated by the grammars in part (a) and (b) above. • (d) S  aSa | bSb | cSc |  (The grammar in problem 4-(b) can also be an answer.) • 7. (a) S  aaSBBCC | aabbcc CB  BC aB  ab bB  bb bC  bc cC  cc  • (b) S  aSBCD | abcd CB  BC DB  DB DC  CD • aB  ab bB  bb bC  bc cC  cc • cD  cd dD  dd

More Related