Exemple #1
0
        private static void ExecuteJumpSearch()
        {
            var array = new int[] { 1, 3, 4, 8, 14, 21 };
            var item  = 40;

            Console.WriteLine($"Array - {string.Join(",", array)}");
            Console.WriteLine($"Jump Search - {item}");
            var algo  = new JumpSearch();
            var index = algo.Search(array, item);

            Console.WriteLine($"Item {item} present at index- {index}");
        }
Exemple #2
0
        static void Main(string[] args)
        {
            while (true)
            {
                //LinearSearch O(n)
                //  LinearSearch linearSearch = new LinearSearch();

                //The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(Log n).
                //  BinarySearch binarySearch = new BinarySearch();


                //The basic idea is to check fewer elements (than linear search) by jumping ahead by fixed steps or skipping some elements in place of searching all elements.
                JumpSearch jumpSearch = new JumpSearch();

                Console.WriteLine("Hello World!");
            }
            //}
        }