Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Changing the format won't give you more resolution which is what your real problem is hee if you print 1 ms with 7 digits you just get 1.0000000 every time. This doesn't help you at all.</p> <p>What you need is a high resolution timer</p> <pre><code>long start = System.nanoTime(); int sortedArr[] = selectionSort(arr1); long elapsed = System.nanoTime() - start; System.out.println("\n///////////SELECTIONSort//////////////"); System.out.println("\nSelection sort implemented below prints a sorted list:"); print(sortedArr); System.out.printf("It took %.3f ms....", elapsed / 1e6); </code></pre> <p>However, if you do this once you are fooling yourself because Java compiles code dynamically and gets fast the more you run it. It can get 100x faster or more making the first number you see pretty useless.</p> <p>Normally I suggest you run loops many times and <em>ignore the first 10,000+ times</em>. This will change the results so much that you will see that the first digit was completely wrong. I suggest you try this</p> <pre><code>for(int iter = 1; iter&lt;=100000; iter *= 10) { long start = System.nanoTime(); int[] sortedArr = null for(int i=0;i&lt;iter;i++) sortedArr = selectionSort(arr1); long elapsed = System.nanoTime() - start; System.out.println("\n///////////SELECTIONSort//////////////"); System.out.println("\nSelection sort implemented below prints a sorted list:"); print(sortedArr); System.out.printf("It took %.3f ms on average....", elapsed / 1e6 / iter); } </code></pre> <p>You will see you results improve 10x maybe even 100x just by running the code for longer.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload