Java – Convert to any base (Binary, Octal, Hex)

Converting between decimal and an arbitrary base x is done by evenly dividing the decimal number to the base x until the division quotient is zero.   Example: converting 23 (decimal) to binary (base 2): 23 / 2 = 11, remainder 1 11 / 2 = 5, remainder 1 5 / 2 = 2, remainder 1 2 / 2 … Read more

Java – Insertion Sort Algorithm

For this method we need two arrays: source and destination. Elements of the source array will be inserted in the corresponding position, so that in the destination array the order relation will be fulfilled.   Step 1: We copy the first element of the source array into the first position of the destination array. Step … Read more