コード例 #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Enter size of the array:");
            string s = Console.ReadLine();
            int    n = int.Parse(s);

            QuickFind qf = new QuickFind(n);

            qf.Connect(2, 3);

            bool isConnected = qf.isConnected(2, 3);

            Console.WriteLine("2 and 3 :" + isConnected);

            isConnected = qf.isConnected(2, 5);

            Console.WriteLine("2 and 5 :" + isConnected);

            qf.Connect(2, 5);

            isConnected = qf.isConnected(2, 5);
            Console.WriteLine("2 and 5 :" + isConnected);

            isConnected = qf.isConnected(3, 5);

            Console.WriteLine("3 and 5 :" + isConnected);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: nullxor/AlgorithmsCoursera
        static void Main(string[] args)
        {
            QuickFind quickFind = new QuickFind(9);
            
            quickFind.Union(4, 3);
            quickFind.Union(3, 8);
            quickFind.Union(6, 5);
            quickFind.Union(9, 4);

            Console.WriteLine(quickFind.Find(3, 9));
            Console.WriteLine(quickFind);
        }