Files
java-interview-lab/stack-queue/output/01-balanced-parentheses-trace.txt
T

29 lines
1.3 KiB
Plaintext

Balanced brackets: every step of four inputs
============================================
input: {[()]} firstMismatch = -1
read '{' at 0: push '}' waiting for (top first): }
read '[' at 1: push ']' waiting for (top first): ] }
read '(' at 2: push ')' waiting for (top first): ) ] }
read ')' at 3: pop ')', matches waiting for (top first): ] }
read ']' at 4: pop ']', matches waiting for (top first): }
read '}' at 5: pop '}', matches waiting for (top first): (empty)
end of input: waiting for (empty) -> balanced
input: ([)] firstMismatch = 2
read '(' at 0: push ')' waiting for (top first): )
read '[' at 1: push ']' waiting for (top first): ] )
read ')' at 2: expected ']' -> NOT balanced
input: ()) firstMismatch = 2
read '(' at 0: push ')' waiting for (top first): )
read ')' at 1: pop ')', matches waiting for (top first): (empty)
read ')' at 2: stack is empty, nothing to close -> NOT balanced
input: (() firstMismatch = 0
read '(' at 0: push ')' waiting for (top first): )
read '(' at 1: push ')' waiting for (top first): ) )
read ')' at 2: pop ')', matches waiting for (top first): )
end of input: waiting for ) -> NOT balanced, openers left over