private void RevOrderTravel(IBinNode t)
 {
     if (t == null)
     {
         return;
     }
     RevOrderTravel(t.Left);
     RevOrderTravel(t.Right);
     Print(t);
 }
 /// <summary>
 /// 中序線索化的遞迴實現
 /// </summary>
 /// <param name="t"></param>
 private void InThreading(IBinNode t)
 {
     if (t == null)
     {
         return;
     }
     else
     {
         InThreading(t.Left);
     }
 }
        public void Insert(IBinNode node, Position pos)
        {
            if (node == null)
            {
                throw (new InvalidOperationException("不能將空節點插入樹"));
            }
            switch (pos)
            {
            case Position.LEFT: tree.Left = node; break;

            case Position.RIGHT: tree.Right = node; break;
            }
        }
 /// <summary>
 /// 中序線索化
 /// </summary>
 public void InOrderThreading()
 {
     head       = new BinNodeLine("");
     head.RTag  = Tag.THREAD;
     head.Right = head;
     if (tree == null)
     {
         head.Left = head;
     }
     else
     {
         head.Left = tree; prenode = head;
     }
 }
Exemple #5
0
 public TravelBinTree(IBinNode INode)
 {
     tree = INode;
 }
Exemple #6
0
 //指向最近访问过的前驱节点
 public TravelBinTree()
 {
     tree = new BinNodePtr();
 }
Exemple #7
0
 public BinNodePtr()
 {
     element = null; lchild = rchild = null;
 }
Exemple #8
0
 public BinNodePtr(object e)
 {
     element = e; lchild = rchild = null;
 }
 private IBinNode prenode; //指向最近訪問過的前驅節點
 public TravelBinTree()
 {
     tree = new BinNodePtr();
 }
Exemple #10
0
 private void RevOrderTravel(IBinNode t)
 {
     if (t == null) return; RevOrderTravel(t.Left);
     RevOrderTravel(t.Right); Print(t);
 }
Exemple #11
0
 public void Print(IBinNode t)
 {
     Console.Write(t.Element + ",");
 }
 public BinNodePtr(object e, IBinNode left, IBinNode right)
 {
     element = e;
     lchild  = left;
     rchild  = right;
 }
 public void Print(IBinNode t)
 {
     Console.Write(t.Element + ",");
 }
 public TravelBinTree(IBinNode INode)
 {
     tree = INode;
 }
Exemple #15
0
 public void InOrderThreading()
 {
     head = new BinNodeLine("");
     head.RTag = Tag.THREAD; head.Right = head;
     if (tree == null) head.Left = head;
     else
     {
         head.Left = tree; prenode = head;
     }
 }
 public BinNodePtr(object e)
 {
     element = e;
     lchild  = rchild = null;
 }
Exemple #17
0
 public void Insert(IBinNode node, Position pos)
 {
     if (node == null)
         throw (new InvalidOperationException("不能将空节点插入树"));
     switch (pos)
     {
         case Position.LEFT: tree.Left = node; break;
         case Position.RIGHT: tree.Right = node; break;
     }
 }
 public BinNodePtr()
 {
     element = null;
     lchild  = rchild = null;
 }
Exemple #19
0
 //中序线索化的递归实现
 private void InThreading(IBinNode t)
 {
     if (t == null) return;
     else
     {
         InThreading(t.Left);
     }
 }
Exemple #20
0
 public BinNodePtr(object e, IBinNode left, IBinNode right)
 {
     element = e; lchild = left; rchild = right;
 }
Exemple #21
0
 public BinNodeLine(object e, IBinNode left, IBinNode right)
     : base(e, left, right)
 {
     ltag = rtag = Tag.LINK;
 }
 public BinNodeLine(object e, IBinNode left, IBinNode right)
     : base(e, left, right)
 {
     ltag = rtag = Tag.LINK;
 }