假设自上而下按层次 自左至右输入每个结点的一个三元组 N P L R 其 中N 为本结点的元素 P 为其父结点 L 指示N 为P 的左孩子 R 指示N 为P 的右孩子 试写一个建立二元树在内存的双链表示算法 并实现先根 中根 后 根以及层序遍历算法 ">假设自上而下按层次 自左至右输入每个结点的一个三元组 N P L R 其 中N 为本结点的元素 P 为其父结点 L 指示N 为P 的左孩子 R 指示N 为P 的右孩子 试写一个建立二元树在内存的双链表示算法 并实现先根 中根 后 根 [更
#include #include #include using namespace std; const int LH=1; //左子树比右子树高1 const int EH=0; //左右子树一样高 const int RH=-1;//右子树比左子树高1 const int MAX_NODE_NUM=20; //结点数目上限 class AvlNode { int data; int bf; //平衡因子 AvlNode *lchild; AvlNode *rchild; friend
using System; using QueueDs; namespace BinaryTreeDs { public class LinkBiTree { private Node head; //头引用 //头引用属性 public Node Head { get { return head; } set { head = value; } } //构造函数 public LinkBiTree() { head = null; } //构造函数 public LinkBiTree(T v