- a. Read data from a text file containing key words and their page numbers in a book.
There will be several lines of records and each record has the following format:
xxxxx nn nn nn nn
where xxxxx is the keyword followed by 0, 1, or many page numbers. The page
numbers are not necessarily in order.
There can be more than one record for the same keyword and the keyword records
are not necessarily in order.
b. Store each record in a KeyWordLinkedList. The head points to a KeyWordNode
which contains the keyword and a link points to the next PageNode.
c. A PageNode contains a page number and a link to the next PageNode.
d. The page numbers stored in the KeyWordLinkedList should be in order.
e. Create an array of KeyWordLinkedList (KeyWordArray) to store all the keyword
records in the text file.
f. Print out the keywords and the page numbers. The keywords should be in the input
order and the page numbers should be sorted.
- After you have successfully completed step 1, build a binary search tree KeyWordTree
to do the sorting of the keywords. Follow the guidelines below:
a. Create the KeyWordTree with its root being a KeyWordLinkedList.
b. When inserting nodes to the tree, the comparison criterion will be based on the
keyword contained in the head (a KeyWordNode) of the KeyWordLinkedList.
c. Build the KeyWordTree from the KeyWordArray.
d. Print out the keywords and the page numbers from the tree. The keywords and the
page numbers should be in order.