logo - 刷刷题
下载APP
【简答题】

Project 1: Performance Measurement Given a list of ordered N integers, numbered from 0 to N–1, checking to see that N is not in this list provides a worst case for many search algorithms. Consider two algorithms: one is called “ sequential search ” which scans through the list from left to right; and the other is “ binary search ” which is given on our PPT. Your tasks are: (1) Implement an iterative version and a recursive version of sequential search; (2) Implement an iterative version of binary search; (3) yze the worst case complexities of the above two versions of sequential search and that of binary search; (4) Measure and compare the worst case performances of the above three functions for N= 100,500,1000,2000,4000,6000,8000,10000. To measure the performance of a function, we may use C’s standard library time.h as the following: Note: If a function runs so quickly that it takes less than a tick to finish, we may repeat the function calls for K times to obtain a total run time(“ Total Time ”), and then divide the total time by K to obtain a more accurate duration(“ Duration ”) for a single fun of the function. The repetition factor must by large enough so that the number of elapsed ticks is at least 10 if we want an accuracy of at least 10%. The test results must be listed in the following table: The performances of the three functions must be plotted in the same N-running time coordinate system for illustration. project_1_班级_学号_姓名.doc

举报
题目标签:姓名学号班级
参考答案:
参考解析:
.
刷刷题刷刷变学霸