HW#3 --- last modified January 01 1970 00:00:00..
Due date: Mar 21
Files to be submitted:
Names.java
As I mentioned in class I do not want you to use any
Java Classes that help you to do the string operations of your program.
i.e., do not use StringTokenizer or things like substring of String.
To be safe just use character arrays and simulate a PDA.
Purpose: To gain familiarity with context free languages and push down automata. To actually write some code related to these ideas.
Specification:
Do problems 3.1.3, 3.1.8, 3.1.10, 3.2.3, 3.3.2, 3.4.1, 3.5.1, 3.5.2 out of
L&P.
In addition to these book problems each group is responsible for writing
a program called Names.java in Java which should be submitted using
the Submit HW link on the border frame of the classpage. Only one member
of any group needs to submit. The code needs to conform to the departmental
coding guidelines for Java and should list each of the groups contributors
in a comment at the start. After compiling your program, I will run it from
the command line with a line like:
java Names james#sally#sally#james+sally#sarah#sally
I expect you program to output yes or no depending on whether the number of
occurences of first names of your group members is the same on both sides of
the plus sign. In the above example, if james, sally, and sarah
were the group members' first names, the output would be no as there are
four occurrences in the left hand side and just three on the right.
Since the first names of people will vary from group to group, each group's
program should be recognizing a different language.
You can assume the alphabet is the symbols in the first names of your group
members
together with # an +. If the string contains other symbols (in particular,
any upper case letters) you can just output no. If the string does not
contain + or has it more than once you can also output no.
Here are some example strings in the language assuming the group
members names are james, sally, sarah:
majes+yjlly (zero occurrences of the names on either side of the +)
jamessally+sarah#sally (two on each side)
#####sally#sarah#sarah+#########sally##sarahjames######### (three each side)
Point Breakdown
Names.java runs as described above. |
2pts
|
Book problems 1pt each. |
8pts
|
Total |
10pts |
|