Are empty Binary Search Trees valid?

前端 未结 7 1449
挽巷
挽巷 2021-01-12 12:48

I have two questions regarding binary search trees, both about empty trees.

  1. Is an empty tree (null) valid?
  2. Is a root node without children valid?
7条回答
  •  感情败类
    2021-01-12 13:25

    Yes both conditions are true. For a binary tree, each node can have zero, one, or two children. If a tree has only a root node and no other node then it is called a NULL tree.

提交回复
热议问题