Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

When considering the push() and pop() operations for a stack- how coul.docx

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige

Hier ansehen

1 von 1 Anzeige

When considering the push() and pop() operations for a stack- how coul.docx

Herunterladen, um offline zu lesen

When considering the push() and pop() operations for a stack, how could a compiler program use a stack to implement delimiter matching. For example, matching delimiter strings could be: “{”, “}”, “(”, “)”, and “/*”, and “*/”.
Solution
private static final char[] opening = new char[]{\'(\', \'[\', \'{\'};
private static final char[] closing = new char[]{\')\', \']\', \'}\'};
and stack integer can be denoted so that if the value is -1 then there is an error else matched.
How stack is used in delimiter matching:
6) if the stack is not empty finally at the end then report missing right delimiter error
.

When considering the push() and pop() operations for a stack, how could a compiler program use a stack to implement delimiter matching. For example, matching delimiter strings could be: “{”, “}”, “(”, “)”, and “/*”, and “*/”.
Solution
private static final char[] opening = new char[]{\'(\', \'[\', \'{\'};
private static final char[] closing = new char[]{\')\', \']\', \'}\'};
and stack integer can be denoted so that if the value is -1 then there is an error else matched.
How stack is used in delimiter matching:
6) if the stack is not empty finally at the end then report missing right delimiter error
.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Weitere von todd571 (20)

Aktuellste (20)

Anzeige

When considering the push() and pop() operations for a stack- how coul.docx

  1. 1. When considering the push() and pop() operations for a stack, how could a compiler program use a stack to implement delimiter matching. For example, matching delimiter strings could be: “{”, “}”, “(”, “)”, and “/*”, and “*/”. Solution private static final char[] opening = new char[]{'(', '[', '{'}; private static final char[] closing = new char[]{')', ']', '}'}; and stack integer can be denoted so that if the value is -1 then there is an error else matched. How stack is used in delimiter matching: 6) if the stack is not empty finally at the end then report missing right delimiter error

×