Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Speed up approaches for your task:</p> <p><strong>1. Use integers</strong></p> <p>Convert the strings to integers (store the strings in an array and use the position for the tupples.</p> <p>String[] words = {"ball", "chair", "box"};</p> <p>In tuppls ball now has number 0 (pos 0 in array) , chair 1, box 2. comparing ints is faster than Strings.</p> <p><strong>2. Avoid recursion</strong></p> <p>Recursion is slow, due the recursion overhead.<br> For example look at binarys search algorithm in a recursive implementatiion, then look how java implements <code>binSearch()</code> (with a while loop and iteration)</p> <p>Recursion is helpfull if problems are so complex that a non recursive implementation is to complex for a human brain.</p> <p>An iterataion is faster, but not in the case when you mimick recursive calls by implementing your own stack.</p> <p>However you can start implementing using a recursiove algorithm, once it works and it is a suited algo, then try to convert to a non recursive implementation</p> <p><strong>3. if possible avoid objects</strong></p> <p>if you want the fastest, the now it becomes ugly!</p> <p>A tuppel array can either be stored in as array of class Point(x,y) or probably faster, as array of int:<br> Example: (1,2), (2,3), (3,4) can be stored as array: (1,2,2,3,3,4) This needs much less memory because an object needs at least 12 bytes (in java). Less memory becomes faster, when the array are really big, then your structure will hopefully fits in the processor cache, while the objects array does not.</p> <p><strong>4. Programming language</strong></p> <p>In C it will be faster than in Java.</p>
 

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