private void Start() { char[] data = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' };//这个是我们要存储的数据 BiTree <char> tree = new BiTree <char>(10); for (int i = 0; i < data.Length; i++) { tree.Add(data[i]); } //先序遍历 tree.FirstTraversal(); //中序遍历 tree.MiddleTraversal(); //后序遍历 tree.LastTraversal(); //层级遍历 tree.LastTraversal(); }
static void MenuCilcked() { char[] data = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' }; BiTree <char> tree = new BiTree <char>(10); for (int i = 0; i < data.Length; i++) { tree.Add(data[i]); } tree.FirstTraversal(); Debug.Log("---------------"); tree.MidTraversal(); Debug.Log("---------------"); tree.LastTraversal(); }