Computer Science 202, Programming Assignment 2, Spring 1998
Due Date: February 20, 1998
Given the information in http://www.csc.tntech.edu/~mjkosa/202/s98/p2/,
implement the operations whose prototypes are
in priqueueint.h. Your implementation will be stored in the priqueueimp.c
file. You will also implement the operations whose prototypes are in
itemint.h, and that implementation will be stored in the itemimp.c
file.
You will test your operations via a demonstration program, which
will be stored in the p2main.c file.
The demonstration program will use priority queues (the abstract data type
that you have implemented) to analyze another kind of HTML file. The files
that you will be analyze will have lines of the following form:
text
where the # denotes a positive integer number between 1 and 15. Your program
will need to make sure that the numbers in the and tags are the same
on a given line. The tags are not case-sensitive, i.e.
and are
equivalent.
Here is a sample file.
Almost largest
Almost almost largest
Largest
This
Smallest
is
Almost smallest
not
all
there is
The number will indicate the priority of the item. In a Web browser, the
height of the text would depend on the number; a bigger number would indicate
taller text. Your program will ask the user for an input file name and an
output file name. Then it will compute the average heading size for the file,
the largest heading size, the smallest heading size, the number of headings of
each size (from largest to smallest), and display the text, grouped by heading
sizes from largest to smallest. The headings with the same heading size will
be displayed in the order in which they were found in the file. All output
will be written to the output file. You are to use the priority queue
operations to complete each of these tasks.
For the sample file, the average heading size is 5.8, the smallest heading
size is 1, the largest heading size is 9.
Heading size Number of headings
------------ ------------------
9 2
8 2
7 2
4 2
1 2
Text grouped by heading size
Heading size Headings
------------ --------
9 Largest
all
8 Almost largest
this
7 Almost almost largest
is
4 Almost smallest
there is
1 Smallest
not