I need algorithms that will check whether given expression is infix, postfix or prefix expression. I have tried a method by checking first or last 2 terms of the string e.g.
+AB if there is an operator in the very first index of string then its a prefix
AB+ if there is an operator in the very last index of string then its a postfix
else it is an infix.
But it doesn't feel appropriate so kindly suggest me a better algorithim.