zoukankan      html  css  js  c++  java
  • Algs4-1.4DoublingRatio

    图片
     public class DoublingRatio
    {
        public static double timeTrial(int N)
        {
            int MAX=1000000;
            int[] a=new int[N];
            for(int i=0;i<N;i++)
                a[i]=StdRandom.uniform(-MAX,MAX);
            Stopwatch timer=new Stopwatch();
            int cnt=ThreeSum.count(a);
            return timer.elapsedTime();
        }
       
        public static void main(String[] args)
        {
           double prev=timeTrial(125);
           for (int N=250;true;N+=N)
           {
               double time=timeTrial(N);
               StdOut.printf("%6d %7.1f  ",N,time);
               StdOut.printf("%5.1f ",time/prev);
               prev=time;
           }
        }
    }
  • 相关阅读:
    Leetcode
    算法
    手写代码注意点 -- HashMap
    Batch
    Batch
    Tomcat
    微服务
    Java 基础
    Maven
    算法
  • 原文地址:https://www.cnblogs.com/longjin2018/p/9854370.html
Copyright © 2011-2022 走看看