Q1 - Q4 are related to the ADT material. In the lecture, we talked about "outside the black box" and
"inside the black box". The related discussion question will give you some practice with working
"outside the black box". The assignment is intended to help you think about "inside the black box", by
having you look at alternative representations. In Q1, you look at an alternative to binary. In Q2, you
look at an where stuff might be stored as a consequence of a selected implementation. In Q3 and Q4,
you look at an alternative data structures to leverage the fact that many locations in a standard array
might always be empty. In Q6 and Q7 you look at how the time is affected by the underlying cost of the
algorithm. Question 4 is extra credit.
1. Show how nonnegative numbers can be represented in an imaginary ternary computer using trits
(0,1,2) instead of bits (0,1). Why don't we do things this way?
Decimal Ternary
0 0
1 1
2 2
3 10
4 11
5 12
6 20
7 21
8 22
9 100
10 101
There are no nonnegative integers that can be represented using ternary notation and trits that
cannot be represented using binary notation and bits. There are also no nonnegative integers that
can be represented using bits that cannot be represented using trits.
Why don’t we do things this way?
Binary computers are more common than ternary computers because a computer is an electrical
device whose components are capable of two states only - on or off. Since the computer’s memory is
simply a group of switches that may be only on or off, any bit of information stored in the computer at
any time must have one of two mutually exclusive values : 1 (on) or 0 (off).
2. If each element of an array RM,with 10 rows and 20 columns, stored in row major order, takes
four bytes of space, where the first element of RM starts at 100, what is the address of RM[5][3] and
RM[9][19]?
Using the zero-based arrays common to current programming languages: RM[5][3] :
100 + (5 * 20 * 4) + (3 * 4) = 512
RM[9][19] : 100 + (9 * 20 * 4) + (19 * 4) = 896