Are empty Binary Search Trees valid?

前端 未结 7 1318
挽巷
挽巷 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:14

    Is an empty tree (null) valid?

    There is no tree if it is empty. Hence the question of validity doesn't arise.

    Is a root node without children valid?

    Yes. That is a tee with only one element in it.

提交回复
热议问题