Category: general
We need to bear in mind the Ahmdal’s Law when doing code optimisation. The speed up can be described in the following equation: Speedup = time_old /time_new Where, the …
There is a popular IQ question, e.g. according to the first few number patterns, find the answer to the input: 1234 = 0 4567 = 1 2345 = 0 …
Hashing is an important technique in Computer Science. There are many cases that you can use Hash to speed up your algorithms (e.g. by reducing from O(n^2) to O(n) …
I have seen a naive implementation at work today (written by a colleague). My colleague intends to generate a number that is power of two, and the number is …
In Java Math Package, there is a pow function with returns double type. However, we can speed up this if only integer (long type) parameters are required, i.e. compute integer power …