CSC148H1 Lecture Notes - Lecture 8: Delimiter, Docstring
katrinasavvy and 38715 others unlocked
1
CSC148H1 Full Course Notes
Verified Note
1 document
Document Summary
Csc148: lecture 8: stack api and sack api. References: code seen in the pictures can be found on the csc148 website: http://www. teach. cs. toronto. edu/~csc148h/winter/ Computer scans and encounters left bracket and keeps track of it for later reference. If what it encounters is not a left or right bracket, the computer ignore it: use stack to keep track of brackets. Write a function using class stack that: string with no parentheses is balanced, string that beings with a left parenthesis ( ends with a right parenthesis, also applies for brackets and braces [], {} If the left delimiter is found, add it to the stack. If it"s not empty -> stack has some left brackets added to it. Elif left_delim[c] != st. remove: remove delimiter at top and compare it with its match, match with left return st. is_empty. If it"s not empty, there means that there"s a left delimiter left in the stack: no closing right delimiter.