示例#1
0
        /// 
        /// Compare items of Traversed in order List to verify if this is  a binary Search Tree
        ///
        private bool IsBinarySearchTreeTraversingAll(SimpleNode<T> root) {

            _list = new List<T>();

            TraverseInOrder(root);
            
            for(var idx=1; idx<_list.Count; idx++) {

                var prev = _list[idx-1];
                var current = _list[idx];
                
                if(prev.CompareTo(current) >= 0)
                    return false;                                   

            }

            return true;
        }
示例#2
0
 /// Calls Recursive function to a faster traverse to
 /// figure it out if this is a Binary Search Tree
 private bool IsBinarySearchTree_FasterOption(SimpleNode<T> root) {
     T prev = default(T);
     return IsBinarySearchTree_Rec(root, ref prev);
 }