records11 - Tools For Data Abstraction Introduction We...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction We often want computers to process large amounts of data, so we need ways to manipulate lists and other groupings of large amounts of data. To satisfy these needs, we require more than just the few basic data types that are built-into the language. The designers of the language can not possibly anticipate all the different ways in which their language will be utilized, however, they can provide the user with the means to “extend” the language to best suit their particular application. Data abstraction is a way to encapsulate the data details of information. In creating data abstractions we build data groupings that reflect the relationships among various data and allow us to conveniently manipulate large amounts of data. In this course we’ll study two different methods for handling two different types of data abstraction problems: Records: Grouping related data items together. Linked lists: A collection of a large amount of similar or related data. Records Records are a mechanism for data grouping. Each record type is defined within its algorithm. Each record is a heterogeneous collection of data. Data of all different types (including records) are grouped into a single structure. A record is a composite structure composed of some number of fields . Each field has its own type. A data field is an individual data item within a record type. In the C language, records are created using the struct construct. Examples of defining a struct in C struct party { int house_number; int ime_starts; int time_ends; }; Data Abstraction (Records) - 1 Tools For Data Abstraction
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This construct defines the type of the struct that we have named party . Before we can use the struct we need to declare variables to be of this type, just as we do with the built-in primitive types. struct party Halloween_party; NewYears_party: Once this is done, rather than a collection of six variable, we have 2 variables each containing 3 fields. Both variables are identical in structure. If we make a change to the underlying structure (i.e., the underlying type) then it changes for all variables declared to be of that type. Using our example, suppose that we add the following field to the struct: struct party { int house_number; int ime_starts;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

records11 - Tools For Data Abstraction Introduction We...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online