Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11 Data Structures. Understand arrays and their usefulness. Understand records and the difference between an array and a record. Understand the.

Similar presentations


Presentation on theme: "Chapter 11 Data Structures. Understand arrays and their usefulness. Understand records and the difference between an array and a record. Understand the."— Presentation transcript:

1 Chapter 11 Data Structures

2 Understand arrays and their usefulness. Understand records and the difference between an array and a record. Understand the concept of a linked list and the difference between an array and a linked list. After reading this chapter, the reader should be able to: O BJECTIVES Understand when to use an array and when to use a linked-list.

3 Data Structures Data structure uses a collection of related variables that can be accessed individually or as a whole. Data structure a scheme for  organizing related pieces of data.  allowing different operations to be performed on the data. The basic types of data structures include:  files  lists  arrays  records  trees  tables

4 ARRAYSARRAYS 11.1

5 Array Array a fixed-size, sequenced collection of elements of the same data type. The subscripts indicate the ordinal number of the element counting from the beginning of the array.

6 Figure 11-1 Twenty individual variables

7 Figure 11-2 Processing individual variables

8 Figure 11-3 Arrays with subscripts and indexes

9 Figure 11-4 Processing an array

10 Figure 11-5 Frequency array Show the number of elements with the same value found in a series of numbers.

11 Figure 11-6 Histogram A pictorial representation of a frequency array.

12 Figure 11-7- Part I Two-dimensional array

13 Figure 11-8 Memory layout Row-major storage

14 RECORDSRECORDS 11.2

15 Record Record a collection of related elements, possibly of different types, having a single name. Each element in a record is called a field. Difference  Array: all elements – same type  Record: elements – same or different types.

16 Figure 11-9 Records

17 The elements in a record can be of the same or different types. But all elements in the record must be related. Note:

18 LINKEDLISTSLINKEDLISTS 11.3

19 Linked list Linked list an ordered collection of data in which each element contains the location of the next element. Each element contains two parts: data and link. The link contains a pointer (an address) that identifies the next element in the list. Singly linked list The link in the last element contains a null pointer, indicating the end of the list.

20 Figure 11-10 Linked lists

21 Figure 11-11 Node Nodes : the elements in a linked list. The nodes in a linked list are called self-referential records. Each instance of the record contains a pointer to another instance of the same structural type.

22 Figure 11-12 Inserting a node

23 Figure 11-13 Deleting a node

24 Figure 11-14 Traversing a list


Download ppt "Chapter 11 Data Structures. Understand arrays and their usefulness. Understand records and the difference between an array and a record. Understand the."

Similar presentations


Ads by Google