In C#, compare the performance of the sequential search algorithm and the binary search algorithm. Firstly, you
Question:
In C#, compare the performance of the sequential search algorithm and the binary search algorithm. Firstly, you need to create a sorted array having 4999 integers. The values of these integers can be, for example, from 1 to 4999. Then, add a new private Integer data member named compCount that is initialized to 0. In each of the search algorithms, add a line of code right after the critical comparison is made that increments compCount by 1.
(1). Run both methods in C#, searching for the following numbers:
the smallest number in the array, say 1;
the largest number, say 4999;
the median number, say 2500.
(2). Compare the values of compCount after running both methods. That is, when searching the smallest number, the largest number, and the median number in the array, your C# code should have the output answering the following two questions:
What is the value of compCount for each method?
Which method makes the fewest comparisons?