Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you give a person a fish, they eat for a day. If you teach a person to fish...</p> <p>My measures for the quality of an implementation are:</p> <ul> <li><strong>Correctness</strong>: If you aren't getting the right answer in all cases, then it isn't ready</li> <li><strong>Readability/maintainability</strong>: Look at code repetition, understandable names, the number of lines of code per block/method (and the number of things each block does), and how difficult it is to trace the flow of your code. Look at any number of books focused on refactoring, programming best-practices, coding standards, etc, if you want more information on this.</li> <li><strong>Theoretical performance</strong> (worst-case and ammortized): <a href="http://en.wikipedia.org/wiki/Big_O_notation" rel="noreferrer">Big-O</a> is a metric you can use. CPU and memory consumption should both be measured</li> <li><strong>Complexity</strong>: Estimate how it would take an average professional programmer to implement (if they already know the algorithm). See if that is in line with how difficult the problem actually is</li> </ul> <p>As for your implementation:</p> <ul> <li><em>Correctness</em>: I suggest writing unit tests to determine this for yourself and/or debugging it (on paper) from start to finish with interesting sample/edge cases. Null, one item, two items, various numbers of duplicates, etc</li> <li><em>Readability/maintainability</em>: It looks mostly fine, though your last two comments don't add anything. It is a bit more obvious what your code does than the code in the book</li> <li><em>Performance</em>: I believe both are N-squared. Whether the amortized cost is lower on one or the other I'll let you figure out :)</li> <li><em>Time to implement</em>: An average professional should be able to code this algorithm in their sleep, so looking good</li> </ul>
    singulars
    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.
 

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