CS HW #1
Problem 1. Numbers as bits
a) 2 or 2,147,483,648 is the largest amount of seconds that can be represented because
there are two choices for every bit, 0 and31.
31,536,000 seconds= 1 year, therefore 2 divided by the # of seconds in a year is 68.1
years, therefore if 68 years are added to 1970, then in 2038, 31 bits will not be enough.
b) Coins are going to have different values given as powers of 2. The goal is to give
customers the minimum number of coins, only giving them one or none of each type of
coin. Choose the largest valued coin under the value of change you need to give back.
Next, based on the value of the remainder, choose the largest number value coin under
the remainder. Keep doing this process until you end up with 0 as your remainder. This is
the minimum amount of coins that can be given.
Problem 2. Pictures as bits 3
a) A 256color image takes 24 bits, because of the multiplication principle, 256 =
16,777,216 and the log 2f this number is 24. These equations are used because there are
256 choices or shades, and in order for a color to be made three shades must be chosen
(multiplication principle). Also, the log must be taken of this new number because that
gives you the number of bits.
b) You can represent 4,096 colors because 4 bits means that there are 16 shades because of
the following formula= 2 =N. 16 shades by multiplication principle becomes 4,096
c) We h