1. Learn
  2. /
  3. Courses
  4. /
  5. Data Structures and Algorithms in Python

Connected

Exercise

Printing book titles in alphabetical order

This video taught you three ways of implementing the depth first search traversal into binary trees: in-order, pre-order, and post-order.

In the following binary search tree, you have stored the titles of some books.

Graphical representation of a binary search tree.

The tree has been preloaded in the bst variable (line 15):

bst = CreateTree()

Can you apply the in-order traversal so that the titles of the books appear alphabetically ordered?

Instructions

100 XP
  • Check if current_node exists.
  • Call the in_order() function recursively on the appropriate half of the tree.
  • Print the value of the current_node.
  • Call the in_order() function recursively on the other half of the tree.