The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 131 -- Algorithms and Data Structures I
Hints on Project #5

A number of students have struggled with the data structures for this project, so this page will give a few hints.

Figure 11.23 in the book shows a cross-reference tree. Here is a corrected version of that figure:



The registration data will look similar--each student is a node in the tree; that student's courses are contained in a singly-linked list. The student node's data field will be a record with the following fields:

  • student ID (positive, range 1111..9999) -- the student key
  • student name (10-character fixed-length string, e.g., "Mary Smith")
  • header block for a linked list that will store the courses for which this student has registered
The linked list node's data field will contain a course reference number (CRN - positive, range 11..99) -- the course key. Each student will register for a maximum of 3 courses.

Suppose student 1234, Lara Croft, is registered for two courses, 22 and 54. Lara's tree node will look like this:
 


Here are possible declarations of some of the data structures:

SUBTYPE CRNRange IS Positive RANGE 11..99;
PACKAGE RegistrationLists IS NEW Singly_Linked_Lists_Generic(...);

SUBTYPE StudentIDRange IS Positive RANGE 1111..9999;
SUBTYPE StudentName IS String(1..10);

TYPE StudentInfo IS RECORD
  ID: StudentIDRange := 1111;
  Name: StudentName := "zzzzzzzzzz";
  Courses: RegistrationLists.List;
END RECORD;

TYPE TreeNode;
TYPE Tree IS ACCESS TreeNode;
TYPE TreeNode IS RECORD
  Info: StudentInfo;
  Left: Tree;
  Right: Tree;
END RECORD;