Question: Write a program to find the number of comparisons using binary search and the sequential search as follows: (Please use with python) Suppose the sequence

Write a program to find the number of comparisons using binary search and the sequential search as follows: (Please use with python)

Suppose the sequence is a Python list of thousands of elements:

use a random number generator to fill the list

use any sorting algorithm to sort the list we havent cover any sorting algorithm yet feel free to use python list sort method

search list for some items as follows:

Use the sequential search algorithm to search the list

Use the binary search algorithm to search the list.

print the number of comparisons for steps C1 and C2,if the item is found in the list then print its position

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!