Hot answers tagged

1

Taking a single sample and calculating it's duration from the wall clock is an extremely error prone method to compere execution speed. A single OS interrupt and the measured time no longer means anything. to improve the accuracy, you can run the code several times and generate statistics to reduce possibility of outside effects causing errors. You need to ...


1

I think when you posted you expected people to tell you why you code didn't work, not offer you suggestions on how you code could look better, but since you are passing and I am waiting for a build I thought I'd offer advice. Please don't take any of the comments as personal insults, remember that the only way I know about most of these things is because I'...


1

First of all, for the readers: if a node's data can only be positive the evalutation can be cut short at places. Recursive version public static boolean hasPathSum1 (Node node, int sum) { if (node == null) { return sum == 0; } sum -= node.data; return hasPathSum1(node.left, sum) || ...


Only top voted, non community-wiki answers of a minimum length are eligible