Question: provided below is the sample code needed. Please write code use python idlre 3.5 or higher. Be very descriptive. SakaidURI Csc x https://sakaiuri x Interdepartmen


provided below is the sample code needed. Please write code use python idlre 3.5 or higher. Be very descriptive.


SakaidURI Csc x https://sakaiuri x Interdepartmen a Economics- Bs x Free Sports pick x Las Vogas odcia x 2016-17 phoen x YC chegg Study I https//sal CSC 110 Homework 6 Analysis of Algorithms Sample Code We have learned this week, that a linear search (also known as sequential search) is not as efficient as a binary search when we are searching a sorted list. For Homework 5, you wrote a program to search the olympics.bxt file for a year to find the location of the summer Olympics for that year. We now know that since the data file was sorted by year, a bnary search would have been much more efficient. 1, Download the solution for Homework 5 from the attachment below and do the following with the code: a. Add a new function to the program that performs a binary search to find the location of the olympics in the given year. CSC Links You can start with the following skeleton: Schedule def find location Binary yearLiat, locLiat, year) Gradebook Fill i the oode to find the y University Course in the year list and return the associated location from tho location liat Site Info using Binary 3earch Help return location You can find the code for binary search on the Sample Code page of the Sakai web site. It wil need to be modified slightly to fit this problem. You can find the oly file here: mpics.bt b. Insert a counter in the code of each of the two findLocation functions to count the important comparison instructions. At the end of the function, print the number of comparisons made to do the search c. Modify the main function of the code so that it calls BOTH fndLocation functions. d, In the comments of the program, include a discussion about the worst case input for each of the two algorithms along with a description of a comparison of the performa of the two algorithms. When does linear search perform better than binary search? Your output will look something like this: Python 3.5.2 Shel Python 3.5.2 Cv3.5.2:4def2a2901a5 un 26 2016 0:47:25 GCC 4.2.1 CApp d S666 dot 3D] Type copyright "credits" or "LicenseO" for more information. RESTART: /Users/idipip po/Documents/csc 110Vhomework/hw-solutions-fal12 016/hu-6-1-analysis.py Please the name of the data file olympics.txt Enter the year you are interested in: 2004 Binary Search: conps inear Search: conps In 2004 the Olympics were held in Athens, Greece mainC) PLease the name of the data file olympics.txt Enter the year you are interested in: 1990 Binary Search: conps
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
