Homework 1

22C:18, Spring 1996

Due Tuesday Jan. 23, 1996, in discussion

Douglas W. Jones

This assignment begins with 2 review questions that are not as much specific to the material in the book as they are to material you should have learned in prior courses or work experience. The final 3 questions focus on material central to success in the remainder of this course!

  1. Part A: Write, in legal Pascal or C, the declarations necessary to declare a binary tree where each node contains an integer field called value.

    Part B: Write, in legal Pascal or C, the declarations of a recursive function that will return the total of all the value fields in a tree when given, as a parameter, a pointer to the root vertex of that tree.

  2. Write, in legal Pascal or C, a little program that reads a number base (an integer from 0 to 35) and then a positive integer written in that base and then prints that number as a decimal number. You need not run the program, nor should the program waste effort on fancy I/O. The focus of this assignment is on the number-base conversion algorithm!

  3. Convert the following numbers to base 10:

    From base 5: 41 432 4321
    From base 8: 35 666 4321
    From base 16: A DAD FEED

  4. Convert the numbers 10, 100 and 1000 from base 10 to:

    Base 5
    Base 8
    Base 16

  5. Convert the following numbers from base 16 to base 2 and then to base 8:

    F0E1D2C3
    B4A59687