1. 학습
  2. /
  3. 강의
  4. /
  5. Data Structures and Algorithms in Python

Connected

연습 문제

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?

지침

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.