stack and infix,prefix,postfix
stack and infix,prefix,postfix 12589.201580
Popular in CS II data structures
Gilson Dos Santos
verified elite notetaker
Popular in Computer Science and Engineering
This 0 page Class Notes was uploaded by Gilson Dos Santos on Monday November 2, 2015. The Class Notes belongs to 12589.201580 at Kent State University taught by Dr. Jonathan Maletic in Fall 2015. Since its upload, it has received 44 views. For similar materials see CS II data structures in Computer Science and Engineering at Kent State University.
Reviews for stack and infix,prefix,postfix
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 11/02/15
Gilson Dos Santos 21 october ADTStack datablock of memory operationspushpop we can only see the top of stackTOS first one to be push in will be the last one to be poped out First In Last 0utFILO stackhpp const int cap100 because is constant templatelttypename Tgt class stack dont need the dynamic memory operations public stackTOS1 different way of initializingpreferred the compiller can optimize it better time saving bool isEmptyconstreturn TOS1 returns true or false bool isFUllconstreturn TOScap1 modifiers operations void pushT T POD private T scap int TOS empty top of stack is 1 on the hpp file else the compiler will not be able to find it template lttypename Tgt void stackltTgtpushT x assertisFull to prevent stack overflow sTOSx pre increment because we want TOS to increase before we do the operations templatelttypename Tgt T stackltTgtp0p assertisEmpty return STOS we used post decrement because we want TOS to decrease after we are done with the operation complicated problems on computer programing made easier with stacks 345 precedences rules infiX notation 345 easier for us but difficult for compilers post fixoperators at the end345 prefixoperators at the begining245 convert infix to prepost fix 34572 1FUlly parantesize expression 34572 2move operator to correspond leftPreright post 3set rid of parans Note order of operations Neve changes prefix 34572 postfix 34572 october 26 exprfull parantesize infix expressionvalid Sstack whilenot done with expr for postfix expressions tnexttokenexpr assign t one by one with the expression ift3939 checks for when we reached the end of the expression in parentesys assigns the variables and adds then to the stack rhsSpop OP5POP lhsSpop Spushlhsrhsop else ift3939 Spusht result is on top of stack Evaluete postfix epressionvalid exprpost fix expression whilenot done with expr tnexttokenexpr tokens are the expression we want in this case a number or operator ifisopreatort rhsSpop lhsSpop SpushEvallhstrhs else Spusht result is on top of stack