comparisons using the binary search and sequential search algorithms

Aug 23, 2016 at 10:17am

Hi guys can you please help me with the code that emplements the solution of the question below.

thatnk you in advance for your
Write a program to find the number of comparisons using the binary search and sequential search algorithms as follows:
Suppose list is an array of 1000 elements.
a. Use a random number generator to fill list.
b. Use any sorting algorithm to sort list. Alternatively, you can use the function insertOrd to initially insert all the elements in the list.
c. Search the list for some items, as follows:
i. Use the binary search algorithm to search the list. (You might need to modify the algorithm to count the number of comparisons.)
ii. Use the binary search algorithm to search the list, switching to a sequential search when the size of the search list reduces to less than 15. (Use the sequential search algorithm
for a sorted list.)
d. Print the number of comparisons for Steps c.i and c.ii. If the item is found in the list, then print its position.
Aug 23, 2016 at 11:10am
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Topic archived. No new replies allowed.