1.What is the depth of the tree in the Figure ?
算法与数据结构--树的有关习题
Answer:树的深度=根节点到最远叶子的距离,最远:A-B-E-J-L(M),有四条边,所以树的深度为4.
2.Give the prefix, infix, and postfix expressions corresponding to the tree in the figure.
算法与数据结构--树的有关习题
Answer:先序遍历:先节点–再左子树–再右子树;
中序遍历:先左子树–再节点–再右子树;
后序遍历:先左子树–再右子树–再节点.
prefix:-**ab+cde;
infix:((ab)(c+d))-e;
postfix:ab*cd+*e-

3.a. Show the result of inserting 3, 1, 4, 6, 9, 2, 5, 7 into an initially empty binary search tree.
b. Show the result of deleting the root.
算法与数据结构--树的有关习题
Answer:a.二叉查找树以中序遍历的方式遍历,按照中序排列规则插入元素画出图像即可;
b.根节点有两个直接相连的子节点,用右边子树上的最小元素替换该节点即可.

相关文章:

  • 2021-11-28
  • 2021-09-20
  • 2021-11-02
  • 2021-11-13
  • 2022-01-01
  • 2022-12-23
  • 2021-04-22
猜你喜欢
  • 2021-12-05
  • 2021-12-24
  • 2021-08-22
  • 2021-08-12
相关资源
相似解决方案