Trace the execution of the language-recognition algorithm described in the previoussection for each of the following strings, and show the contents of the stack at each step.


a. a$a
b. ab$ab
c. ab$a
d. ab$ba
(Stack contents are listed from top to bottom.)


a.
aStack: a
inLanguage: true
stackTop: a
aStack:
The while loop exits because we are at the end of the string.
inLanguage is true and aStack is empty, so a$a is in the language.
?
b.
aStack: a
aStack: b a
inLanguage: true
stackTop: b
aStack: a
ch: $
ch: a
stackTop != ch, so inLanguageis set to false.
The while loop exits because inLanguage is false.
inLanguage is false, so ab$ab is not in the language.
c.
aStack: a
aStack: b a
inLanguage: true
stackTop: b
aStack: a
ch: $
ch: a
stackTop != ch, so inLanguage is set to false.
The while loop exits because inLanguage is false.
inLanguage is false, so ab$a is not in the language.
d.
aStack: a
aStack: b a
inLanguage: true
stackTop: b
aStack: a
ch: $
ch: b
stackTop == ch
stackTop: a
aStack:
ch: a
stackTop == ch
The while loop exits because we are at the end of the string.
inLanguage is true and aStack is empty, so ab$ba is in the language.

Computer Science & Information Technology

You might also like to view...

"Works Cited" or "References" are terms used by some reference manuals for a (n) ________, a list of works cited or consulted by an author

Fill in the blank(s) with correct word

Computer Science & Information Technology

?A host that provides storage space for saving and retrieving records is called a _____.

A. ?spool server B. ?cast server C. ?proxy server D. ?file server

Computer Science & Information Technology

The numeric score that affects your future ability to obtain credit is your ____.?

A. ?credit score B. ?netiquette C. ?identity D. ?pin number

Computer Science & Information Technology

Using RSLogix 5000 software, why is configuring I/O modules a manual process rather than having a "read I/O configuration feature" as found in RSLogix 500 software?

What will be an ideal response?

Computer Science & Information Technology