2 - Linear Lists
Published online by Cambridge University Press: 10 November 2016
Summary
Managing Data Storage
In our first steps as programmers, we often write short programs with a quite limited number of variables. Very soon, however, the programming tasks get more involved, and we need some advanced tools to manage efficiently the increasing number of elements dealt with by our programs. This is the role of what has become known as Data Structures, which are the subject of this book.
When coming to organize the data we are supposed to handle, we shall deal with entities called records, like the one in Figure 2.1, representing, in this chapter's running example, the information about a given student at some university. A record may be divided into fields, each standing for a data item relating to the given student, like the name, given name, address, field of study, a list of courses and their grades, etc. One of the fields is particular in that it will serve to identify the records and to distinguish between them. It is emphasized in Figure 2.1, its content is called here ID number, and the assumption will be that different records have different IDs.
Our task is to maintain a large collection of such records, allowing efficient access and updates. Maintaining means here to store the records in such a way that queries about any of their data fields may be processed quickly, but also to facilitate subsequent changes, like insertions of new records, or deletion of those that are not needed any more. Getting back to our example, a student might ask what grade she got on a specific course, a new record has to be allocated if a new student enrolls, and the records of students who finished their studies should be erased from the current list and possibly transferred to another collection, dealing with alumni.
The technical problem of processing records with variable length fields may be overcome by storing the records wherever convenient, and keeping only a list of fixed length (ID, pointer) pairs. We may then restrict our attention to processing only the list of IDs, and shall henceforth narrow our discussion to the handling of the identifying field alone.
- Type
- Chapter
- Information
- Basic Concepts in Data Structures , pp. 14 - 32Publisher: Cambridge University PressPrint publication year: 2016