When to use Preorder, Postorder, and Inorder Binary Search Tree Traversal strategies

前端 未结 5 1387
萌比男神i
萌比男神i 2020-12-12 08:47

I realized recently that while having used BST\'s plenty in my life, I\'ve never even contemplated using anything but Inorder traversal (while I am aware of and know how eas

5条回答
  •  眼角桃花
    2020-12-12 09:21

    If I wanted to simply print out the hierarchical format of the tree in a linear format, I'd probably use preorder traversal. For example:

    - ROOT
        - A
             - B
             - C
        - D
             - E
             - F
                 - G
    

提交回复
热议问题