pop the top operator from the operator stack call this the topop if topop is +-*or then operate on the number stack by popping the operandsdoing the operationand pushing the result if topop is left paren then the given operator should be right paren if sowe are done operating and we return immediately when the precedence of the given operator is greater than the precedence of topop we terminate the loop and push the given operator on the operator stack before returning from operating example to see how this algorithm works it will help to look at an example in the figures the right-most underlined token is the token currently being processed and all tokens to the left have already be processed the operand stack and the operator stack are labeled in the diagrams the topop operator and the current operator are given as well in fig the tokens have been processed and pushed onto their respective stacks the right paren is now being processed and operate was called to process this operator in the operate procedure the topop is "+and "+has higher precedence than ")so the right paren cannot be pushed on top of the addition operator sowe pop the operator stack and operate since we popped "+we then pop the two numbers from the operand stackadd them togetherand push the result as shown in fig after pushing the on the stack we found that the top operator was left paren in that case we popped the left paren and returned immediately leaving just the single left paren on the operator stack then the evaluator proceeded by finding the "*operator and pushing it and then finding the and pushing it on the operand stack nextthe "-operator cannot be pushed onto the operator stack because its precedence is lower then "*operate is called and the topop dictates that we pop two numbersmultiply themand push the result as shown in fig the "-operator has higher precedence than the "(so it is just pushed onto the operator stack the is processed and pushed onto the operand stack as shown in fig to finish up the evaluation of the infix expressionoperate is called one more time with ")as the operator this forces the to be subtracted from the leaving on the operand stack and the operator stack empty the final result is and the evaluator pops the result from the operand stack and returns it as the result and that is how the python eval function works it turns out that the python eval function is bit more sophisticated than this example howeverthe effect of evaluating simple infix expressions is the same radix sort the radix sort algorithm sorts sequence of strings lexicographicallyas they would appear in phonebook or dictionary to implement this algorithm the strings are this copy belongs to 'acha