Question

Language = c++ Write a program to find the number of comparisons using the binary search...

Language = c++

Write a program to find the number of comparisons using the binary search and sequential search algorithms as follows: o Suppose list is an array of 1000 elements.

o Use a random number generator to fill the list.

o Use the function insertOrd to initially insert all the elements in the list.

o You may use the following function to fill the list:

void fill(orderedArrayListType& list)

{

      int seed = 47; int multiplier = 2743;

                                      int addOn = 5923;

                                      while (list.listSize() < size)

                                      {

                                         list.insertOrd(seed);

                                         seed = int((seed * multiplier + addOn) % 100000);

                                      }

}

o Search the list for some items, as follows (you need to count the number of comparisons):

1. Use the sequential search algorithm to search the list ().

2. Use the binary search algorithm to search the list ().

3. 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)

o Print the number of comparisons for steps 1, 2, and 3 if the item is found in the list, then print its position.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Language = c++ Write a program to find the number of comparisons using the binary search...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT