Presentation is loading. Please wait.

Presentation is loading. Please wait.

©Brooks/Cole, 2003 Chapter 11 Data Structures. ©Brooks/Cole, 2003 Understand arrays and their usefulness. Understand records and the difference between.

Similar presentations


Presentation on theme: "©Brooks/Cole, 2003 Chapter 11 Data Structures. ©Brooks/Cole, 2003 Understand arrays and their usefulness. Understand records and the difference between."— Presentation transcript:

1 ©Brooks/Cole, 2003 Chapter 11 Data Structures

2 ©Brooks/Cole, 2003 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 ©Brooks/Cole, 2003 ARRAYSARRAYS 11.1

4 Figure 11-1 Twenty individual variables

5 ©Brooks/Cole, 2003 Figure 11-2 Processing individual variables

6 ©Brooks/Cole, 2003 Figure 11-3 Arrays with subscripts( 下標 ) and indexes

7 ©Brooks/Cole, 2003 Figure 11-4 Processing an array

8 ©Brooks/Cole, 2003 Array Applications Frequency arrays Frequency arrays –A frequency array shows the number of elements with the same value found in a series of numbers. (Fig. 11.5) Histograms Histograms –A histogram is a pictorial ( 圖示的 ) representation of a frequency array. (Fig. 11.6)

9 ©Brooks/Cole, 2003 Figure 11-5 Frequency array

10 ©Brooks/Cole, 2003 Figure 11-6 Histogram

11 ©Brooks/Cole, 2003 Figure 11-7- Part I Two-dimensional array

12 ©Brooks/Cole, 2003 Figure 11-8 Memory layout “ Row-major ” storage “ Row-major ” storage

13 ©Brooks/Cole, 2003 RECORDSRECORDS 11.2

14 Records A record is a collection of related elements, possibly of different types, having a single name. A record is a collection of related elements, possibly of different types, having a single name. Each element in a record is called a field. Each element in a record is called a field. A field is the smallest element of named data that has meaning. A field is the smallest element of named data that has meaning. Fig. 11.9 Fig. 11.9

15 ©Brooks/Cole, 2003 Figure 11-9 Records

16 ©Brooks/Cole, 2003 The elements in a record can be of the same or different types. But all elements in the record must be related. Note:

17 ©Brooks/Cole, 2003 LINKEDLISTSLINKEDLISTS 11.3

18 Linked lists A linked list is a ordered collection of data in which each element contains the location of the next element. A linked list is a ordered collection of data in which each element contains the location of the next element. Each element contains two parts: Each element contains two parts: –Data: the data parts holds the useful information –Link: the link is use to chain the data together Example: singly linked list (Fig. 11.10) Example: singly linked list (Fig. 11.10)

19 ©Brooks/Cole, 2003 Figure 11-10 Linked lists Null pointer: indicate the end of the list Null pointer: indicate the end of the list

20 ©Brooks/Cole, 2003 Figure 11-11 Node A node in a linked list is a record that has at least two fields: one contains the data, and the other contains the address of the next node in the sequence A node in a linked list is a record that has at least two fields: one contains the data, and the other contains the address of the next node in the sequence

21 ©Brooks/Cole, 2003 Operations on linked lists Inserting a node Inserting a node Deleting a node Deleting a node Searching a list Searching a list Retrieving a node Retrieving a node Traversing a list Traversing a list Coping a list … and so on Coping a list … and so on

22 ©Brooks/Cole, 2003 Figure 11-12 Inserting a node

23 ©Brooks/Cole, 2003 Figure 11-13 Deleting a node

24 ©Brooks/Cole, 2003 Figure 11-14 Traversing a list

25 ©Brooks/Cole, 2003 Key terms Array Array Data structure Data structure Field Field Frequency array Frequency array Histogram Histogram Link Link Linked list Linked list Loop Loop Memory Memory Node Node Null pointer Null pointer One-dimensional array One-dimensional array Pointer Pointer Record Record Row-major storage Row-major storage Search a list Search a list Singly linked list Singly linked list Subscript Subscript Two-dimensional array Two-dimensional array Variable Variable


Download ppt "©Brooks/Cole, 2003 Chapter 11 Data Structures. ©Brooks/Cole, 2003 Understand arrays and their usefulness. Understand records and the difference between."

Similar presentations


Ads by Google