Ejemplo n.º 1
0
        public void Jump()
        {
            Stopwatch sw = Stopwatch.StartNew();
            Rabin     r  = new Rabin();


            Console.WriteLine("");
            int index = jumpsearch(r.arr, r.x);


            Console.Write("Number " + r.x + " is present and  is at index " + index);
            sw.Stop();
            Console.WriteLine("");
            Console.WriteLine("Time taken by JumpSearch is: {0} milli", sw.Elapsed.TotalMilliseconds);
        }
Ejemplo n.º 2
0
        public void linear()
        {
            Rabin     r  = new Rabin();
            Stopwatch sw = Stopwatch.StartNew();


            int result = search(r.arr, r.x);

            if (result == -1)
            {
                Console.WriteLine("not present ");
            }
            else
            {
                Console.WriteLine("Number " + r.x + " is present and is in index  " + result);
            }
            sw.Stop();
            Console.WriteLine("Time taken by LinearSearch is: {0} milli", sw.Elapsed.TotalMilliseconds);
        }
Ejemplo n.º 3
0
        public void binary()
        {
            Stopwatch sw = Stopwatch.StartNew();
            Rabin     r  = new Rabin();
            int       n  = r.arr.Length;

            int result = bs(r.arr, 0, n - 1, r.x);

            Console.WriteLine();
            if (result == -1)
            {
                Console.WriteLine("not present ");
            }
            else
            {
                Console.WriteLine("Number " + r.x + " is present and is in index " + result);
            }
            sw.Stop();

            Console.WriteLine("Time taken by BinaraySearch is: {0} milli", sw.Elapsed.TotalMilliseconds);
        }