IBM interview question

Pre order traversal