CPS 104, Fall 1999
Homework Assignment
#1
Due:
Friday,
10
September
1999
Please monitor the newsgroup
(duke.cs.cps104) for
corrections, updates, and questions answered.
PART A
[total 50 points]
Written assignment: due in class.
- 4.1 in Patterson & Hennessy [3 pts]
- 4.2 [3 pts]
- 4.4 [4 pts]
- 4.5 [4 pts]
- 4.7 (bin to hex only) [3 pts]
- 4.8 [3 pts]
- Consider the sequence 0x414C5453.
- Convert the above sequence to a 32-bit binary number. [3 pts]
- What string of ASCII characters would the above sequence
represent? [3 pts]
- Is the floating point number represented by the above sequence
greater than, or less than, 1?
Give the values of the exponent and the mantissa in hex. [3 pts]
- 4.26 (single precision only). [4 pts]
- 4.27 (single precision only). [4 pts]
- Consider the 32-bit sequence:
1100 0001 0001 0000 0000 0000 0000 0000
- What is the value of the above sequence, when interpreted
as a floating point number? [4 pts]
- Interpret the above sequence as an unsigned integer,
and divide it by 2.
(give the answer in binary) [3 pts]
- The following are two 12-bit two's complement numbers:
A = 0xFD4, B = 0x13A.
Convert to binary and compute A+B and A-B in
12-bit two's complement. Give the answer in hexadecimal.
[3 pts x 2]
PART B
[total 50 points]
Programming assignment. Use submit. Due before midnight.
Write the following programs and
submit them, including a
Makefile and README as assignment
"hw1".
- Circular Doubly Linked List (Memory)
- Modify the linked list example discussed in class (or write you own
program) to implement a doubly linked list with 15 nodes.
Your program should
allocate a single array of nodes and link them together after
allocation using the
"address of" operator. The last node should point to the first node
and the first node should point to the last. The info field of each
node should be an integer giving the position of the node in the
array.
Your program should print the location (address), info field, and
the left and right
pointers for every other node in the list by going around twice.
Your program should allocate an array
and then use pointers to access the nodes;
Do not allocate each node separately.
Note:
you will not receive any credit for this
problem if the tree nodes are allocated via individual calls to new.
[25 points]
- Bit Manipulation
- Write a program to read in a number (in hexadecimal),
reverse the byte order, and print out the result
(in hex). For example, an input of
AABB11FF would give
FF11BBAA as output.
Your program should handle any number representable
as a 32-bit unsigned number. If there are less than
8 hex-digits in the input, you should pad it with 0's.
(note: you must convert the input to a number
and do the bit operations on it)
[25 points]