联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2018-12-24 11:15

Project Bonus:

Goal:Empirical study to compare running times of different Quicksort optimization strategies

Task:Starting with the code for Quicksort given in chapter 7, write a series of Quicksort implementations to test the following optimizations on a wide range of input data sizes N. Try these optimizations in various combinations to try and develop the fastest possible Quicksort implementation that you can.

(a) Look at more values when selecting a pivot.

(b) Do not make a recursive call to qsort when the list size falls below a given threshold, and use Insertion Sort to complete the sorting process. Test various values for the threshold size.

(c) Eliminate recursion by using a stack.

In your main program, first you can generate N different random values to be sorted. It then executes Quicksort in different ways: no optimizations, with optimization (a) or (b) or (c) or their various combinations (such as (a) combine (b), (a) combine (c), (b) combine (c), (a) combine (b) and (c)). It writes out N, optimization strategy, and the running time. It repeats this for N = 10, 100, 1000, 10000, 100000, 1000000.

Please ensure that you generate really random number. You’d better using an appropriate ‘seed’: this is used to initialize the random number generation process.

Deliverables: Your instructor will view the output of your program. In your report, you should present a graph by doing following: Run the program four times for each optimization strategy, and average the running time for each value of N across the four runs and graph the average values. In the graph, the x-axis is N and the Y-axis is the average running time. Plot the points for different optimization strategy.


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp