コード例 #1
0
ファイル: TreeSort.cs プロジェクト: Sanqiang/Algorithm-Win
        public static void Sort(double[] arr)
        {
            int length = arr.Length, i;
            TreeAndGraph.BinarySearchTree btn = new TreeAndGraph.BinarySearchTree(arr[0]);

            for (i = 1; i < length; i++)
            {
                btn.AddTreeNode(arr[i]);
            }

            PutArr(btn.root, arr);
        }
コード例 #2
0
        public static void Sort(double[] arr)
        {
            int length = arr.Length, i;

            TreeAndGraph.BinarySearchTree btn = new TreeAndGraph.BinarySearchTree(arr[0]);

            for (i = 1; i < length; i++)
            {
                btn.AddTreeNode(arr[i]);
            }

            PutArr(btn.root, arr);
        }
コード例 #3
0
        //Two ACS2 Strings, verify whether every character in one string is included in another string
        public static bool verify(string small, string big)
        {
            if (small.Length == 0 || big.Length == 0)
            {
                return(false);
            }
            char[] big_arr = big.ToCharArray();
            Algorithm.TreeAndGraph.BinarySearchTree dic = new TreeAndGraph.BinarySearchTree(big_arr[0]);
            for (int i = 1; i < big_arr.Length; i++)
            {
                dic.AddTreeNode(big_arr[i]);
            }

            foreach (char c in small.ToCharArray())
            {
                if (!dic.FindTreeNode(c))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
        //Two ACS2 Strings, verify whether every character in one string is included in another string
        public static bool verify(string small, string big)
        {
            if (small.Length==0 || big.Length ==0)
            {
                return false;
            }
            char[] big_arr  =big.ToCharArray();
            Algorithm.TreeAndGraph.BinarySearchTree dic = new TreeAndGraph.BinarySearchTree(big_arr[0]);
            for (int i = 1; i < big_arr.Length; i++)
            {
                dic.AddTreeNode(big_arr[i]);
            }

            foreach (char c in small.ToCharArray())
            {
                if (!dic.FindTreeNode(c))
                {
                    return false;
                }
            }

            return true;
        }