def decimal_to_base2(dec):
    """Convert decimal number to binary number by iteration.

    Time complexity: O(d/2).
    Space complexity: O(d/2).
    """
    # Push remainders into stack.
    rem_stack = []
    while dec > 0:
        dec, rem = divmod(dec, 2)
        rem_stack.append(rem)

    # Pop remainders and concat them into binary number string.
    bin_num = ''
    while rem_stack:
        bin_num += str(rem_stack.pop())
    return bin_num