1 / 24

Arrays, Records, and Linked Lists: Understanding Data Structures

This chapter introduces the concepts of arrays, records, and linked lists, and explains the differences between them. It covers the usefulness of arrays and provides examples of their applications, as well as discussing how records and linked lists can be used to organize related pieces of data. By the end of the chapter, the reader will have a solid understanding of these fundamental data structures.

joroy
Download Presentation

Arrays, Records, and Linked Lists: Understanding Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 11 Data Structures

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

  3. Data Structures • Data structureuses a collection of related variables that can be accessed individually or as a whole. • Data structurea 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. 11.1 ARRAYS

  5. Array • Arraya 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. Twenty individual variables Figure 11-1

  7. Processing individual variables Figure 11-2

  8. Arrays with subscripts and indexes Figure 11-3

  9. Processing an array Figure 11-4

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

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

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

  13. Memory layout Figure 11-8 • Row-major storage

  14. 11.2 RECORDS

  15. Record • Recorda 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. Records Figure 11-9

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

  18. 11.3 LINKED LISTS

  19. Linked list • Linked listan 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. Linked lists Figure 11-10

  21. Node Figure 11-11 • 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. Inserting a node Figure 11-12

  23. Figure 11-13 Deleting a node

  24. Traversing a list Figure 11-14

More Related