CS 1320 (Principles of Algorithm Design I):
Homework #2
- Assigned:
- January 28, 2000.
- Due:
- February 4, 2000, at start of class.
- Credit:
- 20 points (10 points per problem).
Instructions
Solve each of the problems below.
This assignment does not ask you to write any programs,
so you need not use a computer unless you prefer
word processor and printer to pencil and paper.
Problems
Converting between number systems
In class (and in the text) we discussed an algorithm to produce
the binary (base 2) representation of any positive integer.
Create an algorithm to produce a base 7 representation of any
positive integer.
Present the algorithm using
pseudocode similar to what we used in class.
Show what happens (step by step)
when you apply your algorithm to convert 53 (base 10) to base 7.
Binary, decimal, and hexadecimal representations
Create a chart that shows the binary, decimal, and hexadecimal
representations of the first twenty nonnegative integers starting
with zero and counting up,
and the first twenty negative integers, starting with -1 and
counting down (i.e., 0, 1, 2, ... and -1, -2, -3 ...).
For the binary and hexadecimal representations, show 16 bits;
assume that negative integers are represented using two's
complement notation.
What to turn in
Turn in your solutions in hard-copy form (can be pencil on paper,
word-processed and printed, etc.).