static void Main()
        {
            // CArray nums = new CArray(10);
            // Random rnd = new Random(100);
            // for(int i = 0; i < 10; i++)
            //     nums.Insert((int)(rnd.NextDouble() * 100));
            // nums.DisplayElements();

            // Console.WriteLine("Before sorting: \n");
            // nums.DisplayElements();
            // Console.WriteLine("During sorting: \n");
            // //nums.BubbleSort();
            // //nums.SelectionSort();
            // nums.InsertionSort();
            // Console.WriteLine("After sorting: \n");
            // nums.DisplayElements();

            Timing sortTime = new Timing();
            Random rnd      = new Random(100);
            int    numItems = 10000;
            CArray theArray = new CArray(numItems);

            for (int i = 0; i < numItems; i++)
            {
                theArray.Insert((int)(rnd.NextDouble() * 100));
            }
            sortTime.startTime();
            theArray.SelectionSort();
            sortTime.stopTime();
            Console.WriteLine("Time for Selection sort: " +
                              sortTime.Result().TotalMilliseconds);

            theArray.Clear();

            for (int i = 0; i < numItems; i++)
            {
                theArray.Insert((int)(rnd.NextDouble() * 100));
            }
            sortTime.startTime();
            theArray.BubbleSort();
            sortTime.stopTime();
            Console.WriteLine("Time for Bubble sort: " +
                              sortTime.Result().
                              TotalMilliseconds);

            theArray.Clear();

            for (int i = 0; i < numItems; i++)
            {
                theArray.Insert((int)(rnd.NextDouble() * 100));
            }
            sortTime.startTime();
            theArray.InsertionSort();
            sortTime.stopTime();
            Console.WriteLine("Time for Insertion sort: " +
                              sortTime.Result().
                              TotalMilliseconds);
        }
 static void Main(string[] args)
 {
     CArray nums = new CArray();
     for (int i = 0; i <= 49; i++)
         nums.Insert(i);
     nums.DisplayElements();
 }
    public static void Main()
    {
        CArray nums = new CArray(); for (int i = 0; i <= 49; i++)

        {
            nums.Insert(i);
        }
        nums.DisplayElements();
    }
        static void Main()
        {
            int    size   = 100;
            CArray primes = new CArray(size - 1);

            for (int i = 0; i < size - 1; i++)
            {
                primes.Insert(1);
            }
            primes.GenPrimes();
            primes.ShowPrimes();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            int    size   = 100;
            CArray primes = new CArray(size);

            for (int i = 0; i <= size - 1; i++)
            {
                primes.Insert(1);
            }

            primes.GenPrimes();
            primes.ShowPrimes();

            Console.Read();
        }
Exemple #6
0
        static void Main(string[] args)
        {
            CArray cArray = new CArray(10);
            Random rnd    = new Random(100);

            for (int i = 0; i < 10; i++)
            {
                cArray.Insert(rnd.Next(0, 1000));
            }
            Console.WriteLine("Before Sorting:");
            cArray.DisplayElements();
            Console.WriteLine("During Sorting:");
            cArray.SelectionSort();
            Console.WriteLine("After Sorting:");
            cArray.DisplayElements();
            Console.ReadKey();
        }