This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Problem Set 1 Solutions CS373  Spring 2011 Due: Thursday Feb 10 at 2:00 PM in class (151 Everitt Lab) Please follow the homework format guidelines posted on the class web page: http://www.cs.uiuc.edu/class/sp11/cs373/ 1. Encoding input and building a DFA [ Category : Design, Points : 15] Let = { , 1 } . i) Create an injective function g that maps the natural numbers to members of * such that  g ( x )  >  g ( y )  only if x > y . (1 Point) Solution: There are many functions that meet the requirements. The key is to create a function that makes the next two parts easy. One such function g ( n ) encodes the individual digits of the number n 's representation in base 5 , then discards any leading zeros. The character map would be 000 , 1 001 , 2 010 , 3 011 , 4 100 . The rst few outputs of the function g would be g (1) = 1 , g (2) = 10 , g (3) = 11 , g (4) = 100 , g (5) = 1000 , and g (6) = 1001 . ii) Design a DFA that recognizes the following language L = { w *  w = g ( n ) , where n = 5 k for a natural number k } . You must use the injective function that you created in part i. To recieve full credit, the DFA can have at most six states. (5 Points) Solution: Using the mapping function above, the DFA is the one recognizing 1000(000) * , shown in Figure 1. Note that any string that is not in the image of g must be rejected by the DFA. Also note that g (1) must be rejected, as 1 = 5 , and is not a natural number. There exists a di erent mapping g that encodes the desired powers of 5 as members of 111(111) * , and the DFA for this takes fewer than six states. iii) Design a DFA that recognizes the following language L = { w *  w = g ( n ) , where n = 25 k for a natural number k } . You must use the injective function that you created in part i. To recieve full credit, the DFA can have at most nine states. (3 Points) Solution: Using the mapping from the solution to part i, the DFA that recognizes members of g (25 k ) is the one that recognizes 1000000(000000) * , shown in Figure 2. Again, using a di erent encoding that still respects the length requirements, it is possible to use fewer than the allowed amount of states. iv) Create a di erent injective function h that maps the natural numbers to members of * . There are no restrictions on h except that it must be injective. (1 Point) Solution: Since there are no more length requirements, h can map 5 k to 1 k , and all other numbers n to n . There are numerous functions that make part v easy. 1 1 1 1 1 1 , 1 Figure 1: A DFA that recognizes 1000(000) * . v) Design a DFA that recognizes the following language L = { w *  w = h ( n ) , where n = 5 k for a natural number k } . You must use the injective function that you created in part iv. To recieve full credit, the DFA can have at most three states. (5 Points) Solution: Using the encoding from part iv, the DFA that recognizes h (5 k ) for natural k is just the DFA that recognizes 11 * . A sample DFA that uses three states is shown....
View
Full
Document
This note was uploaded on 04/28/2011 for the course CS 373 taught by Professor Viswanathan,m during the Spring '08 term at University of Illinois, Urbana Champaign.
 Spring '08
 Viswanathan,M

Click to edit the document details