Question: For the implementation, use your own code for all its components no special library or open source/pirated code should be used. 4. (30 marks)

For the implementation, use your own code for all its components  no special library or open source/pirated

For the implementation, use your own code for all its components no special library or open source/pirated code should be used. 4. (30 marks) Here you are required to code a variation of the binary search in a sorted list of integers. The list is implemented as an array. The search starts with a 1/5th-4/5th strategy wherein the first element compared, when searching for an item in the list, is the 'pivot' element which is at a distance of 1/5th from one end of the list(assuming the end chosen is the start of the 'remaining' list). If there is no match ('pivot' element is not equal to the search key) and if the part of the list that should be examined further for the search is 1/5th part of the list, continue with the same strategy. Whenever the part of the list that should be examined further for the search is of size 4/5th, switch to a binary search once and return to the 1/5th-4/5th strategy. Compare the performance of this strategy with the pure binary strategy by doing an experiment on at least ten lists with 1000+ elements. Tabulate the results (number of comparisons for success and failures). Compare these numbers for a pure binary search. The list could be created by first generating a random positive number and then a random positive increment for the next number (hence the list would be sorted). Search for random values which may or may not be in the list you have generated. The random values to be generated should be in the range of the values in your list.

Step by Step Solution

3.35 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

I can provide you with a Python implementation of the described search strategy and a pure binary se... View full answer

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 Programming Questions!