Вы находитесь на странице: 1из 5

# Computer Networks (ICS-582) Home Work # 1

(201103070)

## King Fahd University of Petroleum and Minerals, Dhahran (Saudi Arabia)

Question (1)
Design an FSA that accepts only valid web addresses. Be sure to accept addresses from the .com and .org domains, and handle an arbitrary amount of directory nesting. Accept at least .html, .htm and .shtml page types.

Solution:

Sub Domain Label/ Prefix with dot . docs. news. email. www. q0 Domain Label microsoft google amidest q1 .com .org

q2
Directory Name

q3
Web Page Name without extension

q3
.html .htm .shtml

q3

Question (2)
Write a regular expression for the language accepted by the NFSA in the figure below?

Solution:
According to the regular expression, the language accepts a from q0 to q1, then it accepts or q1 to q3. After that it if it accepts

b from q1 to q2

b from q1 to q3, then it need to accept aa from q3 to q2 and then q1, b from q1 to q2, then it will accept a (a b a ? ) +
once and goes for the

and the loop continues. While if it accepts loop. So the final expression will look like:

Question (3)
Design an FSA that recognizes finish times for top runners in a marathon. It should handle all times up to 5 five hours. Times are reported to nearest second. Make sure that second, minute and hour have the proper singular or plural endings when appropriate.

Solution: q0
Top Runner 1 took Top Runner 2 took . . Top Runner N took

q1

q3

## 1 second 2 seconds 3 seconds 4 seconds . . . 59 seconds

q2
1 minute 2 minutes 3 minutes 4 minutes . . . 59 minutes

in marathon.

q4

## 1 second 2 seconds 3 seconds 4 seconds . . . 59 seconds in marathon. in marathon.

q5

in marathon.

q4

Question (4)
In Fig. 3.17, why is there a z, s, x arc from q5 to q1?

Solution:
The state q0 is start state and all the arc z, s, x are coming to state q1 from state q0, q5, q1 self-loop while arc z, x are pointing to q1 from q2. If the arc z, s, x from q5 to q1 are not present, it would produce invalid string of arcs. For example we have list of arcs ^, , #, z, s, x. We can found the counter example of invalid path by following the sequence where the arc z, s, x does not come from q5 to q1 and these arcs z, s, x will belongs to others category. The below given sequence of path brings us to invalid string. q0 q1 q2 q5 q0 q1 q0
The output of this string can be s^ss^s# which needs to follow the following path:

q0 q1 q2 q5 q1 q5 q0