SlideServe
Menu
Préférences
© SlideServe · v2026

Understanding Dynamic Structures: Abstract Data Types and Linked Lists

roanna-fleming avatar
13 diapositives · 265 Views · Nov 13, 2014

This lecture explores dynamic structures, focusing on Abstract Data Types (ADTs) and linked lists. It covers variations such as singly linked lists, doubly linked lists, and circular lists, illustrating how references link objects together. Key distinctions between static and dynamic structures are emphasized, along with the importance of abstraction in data structure design. The lecture also provides insight into node implementation and discusses linear data structures like stacks and queues, highlighting their operations and practical analogies.

Understanding Dynamic Structures: Abstract Data Types and Linked Lists - slide 1
01 / 13Understanding Dynamic Structures: Abstract Data Types and Linked Lists
1 / 17

Télécharger la présentation

Understanding Dynamic Structures: Abstract Data Types and Linked Lists
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Lecture 9 • dynamic structures • Abstract Data Types (ADTs) • linked lists • linked list variations: • singly linked list • doubly linked list • circular lists

  2. myboy Smith 407 3.57 Object References • object reference: a variable that stores address of object • A reference can also be called a pointer • They are often depicted graphically: Public class Student { String name; int id; double avg; } Student myboy = new Student(“Smith”, 407, 3.57);

  3. Smith 407 3.57 Jones 821 3.72 References as Links • Object references can create links between objects: A self-referential structure public class Student { String name; int id; double avg; Student next; } Student myboy = new Student(“Smith”, 407, 3.57); Student myboy.next = new Student(“Jones”, 821, 372) myboy

  4. studentList References as Links • References can be used to create a variety of linked structures, such as a linked list:

  5. Static vs. Dynamic Structures • Dynamic structures: • can grow and shrink during execution • components usually accessed via references • Static structures: • fixed size • storage allocated all at once • components are usually named • Arrays are static; once you define the number of elements it can hold, it doesn’t change • NB: This is a different meaning of the word “static” (do not confuse with the static modifier)

  6. Abstraction - again! • Our data structures should be abstractions • That is, they should hide details as appropriate • We want to separate the interface of the structure from its underlying implementation • This helps manage complexity and makes the structures more useful

  7. Intermediate Nodes • The objects being stored should not have to deal with the details of the data structure in which they may be stored • For example, the Student class stored a link to the next Student object in the list • Instead, we can use a separate node class that holds a reference to the stored object and a link to the next node in the list • Therefore the internal representation actually becomes a linked list of nodes

  8. count head 4 data data data next next next data next Singly-Linked Lists • The Student record can be put in a general data field: public class ListElement { Student data; ListElement next; } public class LinkedList { int count; ListElement head; } public class Student { String name; int id; double avg; } Smith 407 3.57 Jones 821 3.72 Papadakis 132 3.88 Narahari 556 3.80

  9. count head 4 data data data next next next data next Smith 407 3.57 Jones 821 3.72 Papadakis 132 3.88 Narahari 556 3.80 Singly-Linked Lists in textbook: • Naming conventions -slightly different in “Java Structures”: public class SinglyLinkedListElement { Object data; ListElement nextElement; } public class SinglyLinkedList { int count; SinglyLinkedListElement head; } public class Student { String name; int id; double avg; }

  10. list Other Dynamic List Implementations • It may be convenient to implement as list as a doubly linked list, with next and previous references:

  11. list count: 4 head tail Other Dynamic List Implementations • It may also be convenient to use a separate header node, with references to both the front and rear of the list

  12. push pop Stacks • A stack ADT is also linear, like a list or queue • Items are added and removed from only one end of a stack • It is therefore LIFO: Last-In, First-Out • Analogy: a stack of plates

  13. dequeue enqueue Queues • A queue is similar to a list but adds items only to the end of the list and removes them from the front • It is called a FIFO data structure: First-In, First-Out • Analogy: a line of people at a bank teller’s window