Exercise on Binary Trees
1. Traversal

In this lesson, we represent binary trees using the following interface:

In this question, you are expected to define three functions named "inorder", "preorder" and "postorder". As you already know, these functions traverse the nodes of a tree in different orders. Refer to this Wikipedia article or your lecture notes for more information. You are not supposed to print anything, just call the "visit" method of TreeNode. Write your solution in the box provided below. You are not supposed to define a main function, which is already defined in the header "chapter1.h".

Difficulty: 2 / 10
Home | About | Contact | Feedback