package com.qiusongde;

import edu.princeton.cs.algs4.StdOut;

public class Exercise2127 {

    public static void main(String[] args) {

        int T = 100;
double previnsert = SortCompare.timeRandomInput("Insertion", 64, T);
double prevselection = SortCompare.timeRandomInput("Selection", 64, T);
double prevshell = SortCompare.timeRandomInput("Shell", 64, T); StdOut.printf("%-10s %-13s %-13s %-13s\n", "N", "Insertion", "Selection", "Shell");
int N = 128;
while(true) { double timeinsert = SortCompare.timeRandomInput("Insertion", N, T);
double timeselection = SortCompare.timeRandomInput("Selection", N, T);
double timeshell = SortCompare.timeRandomInput("Shell", N, T); double ratioinsert = timeinsert/previnsert;
double ratioselection = timeselection/prevselection;
double ratioshell = timeshell/prevshell; StdOut.printf("%-10d %-6.3f %-6.1f %-6.3f %-6.1f %-6.3f %-6.1f\n", N, timeinsert, ratioinsert, timeselection, ratioselection, timeshell, ratioshell); N += N;
previnsert = timeinsert;
prevselection = timeselection;
prevshell = timeshell;
} } }
N          Insertion     Selection     Shell
128 0.005 0.6 0.023 3.8 0.001 0.3
256 0.007 1.4 0.005 0.2 0.005 5.0
512 0.026 3.7 0.025 5.0 0.005 1.0
1024 0.113 4.3 0.084 3.4 0.015 3.0
2048 0.463 4.1 0.331 3.9 0.028 1.9
4096 1.880 4.1 1.317 4.0 0.069 2.5
8192 7.605 4.0 5.251 4.0 0.161 2.3

最新文章

  1. 几个功能强大的系统源码(机票分销、机票预订、OA、手机充值、wifi营销、网络超市、体检平台)
  2. Senparc.Weixin.MP SDK 微信公众平台开发教程(五):使用Senparc.Weixin.MP SDK
  3. 不要轻易delete void*指针,这样会隐藏比较多的错误。
  4. C# 大于屏幕的窗体
  5. C++11实现Qt的信号槽机制
  6. extern 数组
  7. linux设备驱动----利用mdev(udev)自动创建设备文件节点
  8. SCU3502 The Almost Lucky Number
  9. java数据库连接类,已经把数据库操作的方法都封装好了
  10. python学习之day13
  11. Myeclipse安装Activiti
  12. XAF-UI元素概述
  13. 000 Python之禅
  14. 【Android 应用开发】对Android体系结构的理解--后续会补充
  15. C++ 跨语言调用 Java
  16. HTTP协议 (1)
  17. POWER BI报表服务器混合云初了解
  18. PHP分行打印数组-php输出数组方法大全
  19. RabbitMQ 中 Connection 和 Channel 详解
  20. 【内核】几个重要的linux内核文件【转】

热门文章

  1. Python读取文件文件夹并检索
  2. 《Lucene in Action 第二版》第三章节的学习总结----IndexSearcher以及Term和QueryParser
  3. IOS设置图片背景
  4. sublime使用技巧(2)-- 实用插件推荐【持续更新】
  5. 编程算法 - 二叉树的最低公共祖先 代码(C)
  6. Disruptor 创建过程
  7. Openstack(Kilo)安装系列之环境准备(一)
  8. zookeeper应用场景之配置文件同步
  9. Android自定义View分析
  10. 安装Hadoop 1.1.2 (三 安装配置Hadoop)