Homework 2 Submission Rules and Clarifications


What should be the output of your programs?

Your print routines should print at least  the following info so that
we can understand if your  programs are really working:

printTable():


as  table info print:
- directory size

for each block print:
- the number of bits that are same in all integers stored in the block.
- the number of current items stored on the block
- the maximum number of  items that can be stored in the block (16 for
example)
- the items: their values and their counts.
the values should be printed both as decimal and binary.

Example:

directory size: 4

block = ... (any identifier that you can give -  for example an integer)
bits = 3
current_item_count = 6
max_item_count = 8 (this is not related to bits = 3)
Items
- 00000000 00000000 00000000 00000010, 2, 1
- 00000000 00000000 00000000 00000110, 6, 1
- 00000000 00000000 00000000 00000011, 3, 1
- 00000000 00000000 00000000 00000111, 7, 1
- 00000000 00000000 00000000 00001000, 8, 1
- 00000000 00000000 00000000 00000100, 4, 1

block = ....
bits = .....
.......


printHeap():
 

You should print the values and their counts stored in the nodes
similar to the following example:

- print the root value+count and then its children
- print the left child value+count and then its children
- print the right child value+count and then its children.
- .....

Example:

total_number_of_nodes = 46

node:10(1), children:20(1),30(1).
node: 20(1), children: 40(1), 60(1)
node: 30(1), children: 45(1), 35(1).
node 40(1), children: ...........


For programs 3 and 4, the main() routine of your programs should be close
to the following:

- read the items from input file
- while reading items,  build the Table or Heap (you can call insert routine
for every new item - you don't have to implement an efficient BuildHeap).
- print the Table or Heap to output file.


Your programs should take two arguments: input file and output file.
Example:
myhashprogram infile outfile
myheapprogram infile ofile.


What to submit?

  1. Your .cpp and .h files in a floppy diskette.
  2. A report about your programs (hardcopy) (2-3 pages)
  3. Your homework for questions 1 and 2 (hardcopy). (you can combine items 2 and 3)
  4. You will make demo in instructor's office. Both TA and instructor will present at the demo:

An example pseudo-code to print an integer in binary


void
print_decimal_in_binary
(unsigned int x)
{
    unsigned int bit, i;

    for (i=31; i >=0 ; i--)
    {
        bit = 2^i & x; /* bitwise AND operation to get the ith bit of x */
        if (bit)
            cout << "1"; // print to screen. printing to a file should be similar.
        else
            cout << "0";
    }
}