A classic combinatorial problem is to place n queens on an n × n chess board so that no
queen threatens any other queen, that is, so that no two queens are on the same row,
column, or diagonal.
In order to reduce this solution space, it can now be assumed without loss of generality,
that the ith queen is placed in the ith row, thereby avoiding those two queens can be in
the same row.
Infix Expression : Any expression in the standard form like "2*3-4/5" is an Infix(Inorder) expression. Postfix Expression : The Postfix(Postorder) form of the above expression is "23*45/-". Example : infix (1+2)*(3+4)with parentheses: ((1+2)*(3+4))in postfix: 12+34+*in prefix: *+12+34infix 1^2*3-4+5/6/(7+8)paren.: ((((1^2)*3)-4)+((5/6)/(7+8)))in postfix: 12^3*4-56/78+/+in prefix: +-*^1234//56+78Scan
the Infix string from left to right.Initialise
an empty stack.If the
scannned character is an operand, add it to the Postfix string. If
the scanned character is an operator and if the stack is empty Push the
the scanned character is an Operand and the stack is not empty,
compare the precedence of the character with the element on top of the stack(topStack).
If topStack has higher precedence over the scanned character Popthe
stack else Push the scanned character to stack. Repeat
this step as long as …