代写Python实验作业or False as appropriate.
When using Algorithm A, searching for a value that is in the list will requirean average of n/2 comparisons, while in the worse case, searching for a value that1is not in the list will require n comparisons. When using Algorithm B, searchingfor any value will require an average of about logn comparisons. However,sorting the list will take O(nlogn) time.If we are doing a very small number of searches, Algorithm A is preferable.However if we are doing many searches of the same list, Algorithm B is preferablesince the time required to sort the list once is more than offset by the reducedtime for the searches. This is what complexity theory tells us.Your task is to conduct experiments to explore the relationship betweenthe size of the list and the number of searches required to make Algorithm Bpreferable to Algorithm A. See the detailed requirement below:1) Implement two algorithms using Python/Java/C++. When implementingAlgorithm B, you must write your own sort function and your own binarysearch function. You may use any sort algorithm that has complexity inO(nlogn).2) For n = 1000, 2000, 5000, and 10000, conduct the following experiment:- Use a pseudo-random number generator to create a list S containing nintegers.- For values of k ranging from 10 upwards:- Choose k target values, make sure half of which are in S and half arenot in S,- Use Algorithm A to search the list S for the k target values. UseAlgorithm B to search the list S for the k target values.- Determine the approximate smallest value of k for which Algorithm Bbecomes faster than Algorithm A – note that this may be greater than n.Call this value F(n). Create a table or graph showing your values of F(n)as a function of n.To easily create a list of search values, half of which are in S and half of whichare not: - when generating the list S, use only even integer values - randomlychoose some elements of S as the first half of the search list - randomly chooseodd integer values as the second half of the search listYou need to have some functions to record the running time of your algorithms,e.g., the timeit module of Python.3 Assignment Requirements www.3daixie.comThis assignment is to be completed individually. Your need submit your documentedsource code and a report of your proofs, experiment, results and analysis,organized and formatted as described in the document “Assignment Reports”(in the OnQ system). Please combine all files into a .zip archive and submit itto OnQ system. The .zip archive should contain your student number.You can insert pictures into your assignment report, especially for the proofpart.Deadline: By the end of next Thursday (Jan-25,2019)因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:
微信:codinghelp