Notation. To ensure the correctness check of the algorithm and code, an example infix expression (21*5110)3 *11)) and its corresponding prefix expression +*215110*311 are provided.
function buildBinaryTree
input(next-token 't)
if {+ then {
X = create_node()
X.data = t
X.left = buildBinaryTree()
X.right = buildBinaryTree()
}
else {
X = create_node()
X.data = int(t)
X.left = none
X.right = none
}
return(X)