-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment Finished #61
Conversation
S -> r|g|b \ | ||
S -> rSr \ | ||
S -> gSg \ | ||
S -> bSb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the backslashes, but no deduction :)
@@ -53,8 +55,7 @@ In one sentence, explain why. | |||
|
|||
## A1.2 | |||
|
|||
«replace this with your answer» | |||
|
|||
The likely memory complexity O(1), since the only memory needed to traverse a path is for one pointer or two - one on each end - to move through the path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-3
At the very least you have to store the input so you can do the comparison, so you're looking at O(n).
< valid_sentence > ::= "The"< noun_or_adjNoun >< verb_verbAdv > \ | ||
< noun_or_adjNoun > ::= < noun >|< adj >< noun > \ | ||
< noun > ::= "dog"|"cat" \ | ||
< adj > ::= "smelly"|"lazy" \ | ||
< verb_verbAdv > ::= < verb >|< verb >< adv > \ | ||
< verb > ::= "ran"|"ate" \ | ||
< adv > ::= "slowly"|"noisily" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This grammar doesn't allow for repeating adjectives. This structure, where you combine the noud and adjective, makes that harder to implement. I was looking for something like
<sentence> ::= "the" <adjectives> <noun> <verb> <adverb>
<adjectives> ::= "" | <adjectives> <adjective>
<adjective> ::= "lazy" | "smelly"
<noun> ::= "dog" | "cat"
<verb> ::= "ate" | "ran"
<adverb> ::= "slowly" | "noisily" | ""
-3
@@ -109,8 +118,7 @@ Write this grammar using EBNF with common extensions | |||
|
|||
## A2.3 | |||
|
|||
«replace this with your answer» | |||
|
|||
stateMachine.png | |||
|
|||
## Q2.4 (6 points) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only correct, but pretty, too!
--------------|-----------|----------- | ||
S0 | the | S1 | ||
S1 | Lazy | S1 | ||
S1 | Smelly | S1 | ||
S1 | dog | S2 | ||
S1 | cat | S2 | ||
S2 | ran | S3 | ||
S2 | ate | S3 | ||
S3 | slowly | S4 | ||
S3 | noisily| S4 | ||
S3 | EOI | END | ||
S4 | EOI | END |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
@@ -145,17 +164,15 @@ code, include a script or makefile that will do the job. | |||
|
|||
## A2.5 | |||
|
|||
«replace this with your answer» | |||
|
|||
main.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! You gave me a nice program (which is saying something as it's written in C++) with a proper state table. But you also handled all the edge cases: running out of words in the middle of the FSM, and testing both positive and negative cases automatically.
+3 bonus
In general you should never add derived files (such as executables and object files) to a repository. Because they are build for a particular environment, they are pretty much useless to anyone else. |
Sam Yassien
48091645