Project 5 - File Structures


Due : 11:59pm, Thursday 12 August

The aim of this project is to write the general tree from Project 3 to disk so that it can be accessed quickly without having to rescan the hard drive each time a search is conducted.

Extend project 3 by including new functions to do the following:

You should modify the previous Node definition so that it can now cater for both file pointers and memory pointers. This is easily accomplished using the "union" feature of C. Be aware, however, that when changing the value of one variable within a union, the other may change as well. Also, use a fixed-size string storage space (as shown in the sample code).

In order to write the "save" function, you should traverse the nodes and write them to disk as they are encountered, after changing the memory pointers to file pointers. A post-order traveral is most appropriate, with the root node being the last written to disk. Thus, the "search" operation should start by reading in the last node as a starting point - then continuing in a manner analagous to the regular search routine.

Your program must obviously still use the build function (and other routines) from project 3.

Requirements (Contents of submission)

Files

  1. Sample code to implement file structures for a linked list

Solution


Last updated : 13 August 1999 10:00am