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; } }
public TravelBinTree(IBinNode INode) { tree = INode; }
//指向最近访问过的前驱节点 public TravelBinTree() { tree = new BinNodePtr(); }
public BinNodePtr() { element = null; lchild = rchild = null; }
public BinNodePtr(object e) { element = e; lchild = rchild = null; }
private IBinNode prenode; //指向最近訪問過的前驅節點 public TravelBinTree() { tree = new BinNodePtr(); }
private void RevOrderTravel(IBinNode t) { if (t == null) return; RevOrderTravel(t.Left); RevOrderTravel(t.Right); Print(t); }
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 InOrderThreading() { head = new BinNodeLine(""); head.RTag = Tag.THREAD; head.Right = head; if (tree == null) head.Left = head; else { head.Left = tree; prenode = head; } }
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; } }
//中序线索化的递归实现 private void InThreading(IBinNode t) { if (t == null) return; else { InThreading(t.Left); } }
public BinNodeLine(object e, IBinNode left, IBinNode right) : base(e, left, right) { ltag = rtag = Tag.LINK; }