Pre-, In-, Post- order traversal implementation