Linked List Configurations

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

Introduction to Linked Lists In your previous programming course, you saw how data is organized and processed sequentially using an array. You probably.
Chapter Three: Lists, Operators, Arithmetic CS 461.
Data Structures: A Pseudocode Approach with C
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Contd... Objectives Explain the design, use, and operation of a linear list Implement a linear.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
CS 106 Introduction to Computer Science I 12 / 04 / 2006 Instructor: Michael Eckmann.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
CS 1031 Linked Lists Definition of Linked Lists Examples of Linked Lists Operations on Linked Lists Linked List as a Class Linked Lists as Implementations.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Chapter 15 Linked Data Structures Slides prepared by Rose Williams, Binghamton University Kenrick Mock University of Alaska Anchorage Copyright © 2008.
1 Algorithms Queues, Stacks and Records stored in Linked Lists or Arrays.
Linked lists. Data structures to store a collection of items Data structures to store a collection of items are commonly used Typical operations on such.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
Lab - 11 Keerthi Nelaturu. Ordered Structure Using Doubly linked list All elements in the list are arranged in an order Implement the Ordered Structure.
CS162 - Topic #7 Lecture: Dynamic Data Structures –Review of pointers and the new operator –Introduction to Linked Lists –Begin walking thru examples of.
1 Linked Lists Assignment What about assignment? –Suppose you have linked lists: List lst1, lst2; lst1.push_front( 35 ); lst1.push_front( 18 ); lst2.push_front(
Linked List Containers. Useful Linked List Add-Ons Are there new variables/changes to the lists as they have been defined that could make our jobs as.
Skip Lists – Why? BSTs –Worse case insertion, search O(n) –Best case insertion, search O(log n) –Where your run fits in O(n) – O(log n) depends on the.
(c) University of Washington20c-1 CSC 143 Binary Search Trees.
Chapter 12: Pointers, Classes, Virtual Functions, Abstract Classes, and Lists.
Arrays, Link Lists, and Recursion Chapter 3. Sorting Arrays: Insertion Sort Insertion Sort: Insertion sort is an elementary sorting algorithm that sorts.
Data Structures and Algorithm Analysis Dr. Ken Cosh Linked Lists.
Chapter 16: Linked Lists.
CSE 1342 Programming Concepts
Topic 2: binary Trees COMP2003J: Data Structures and Algorithms 2
C++ Programming:. Program Design Including
Data Structures Using C, 2e
Introduction to Linked Lists
CSCI-255 LinkedList.
12 C Data Structures.
How to avoid side effects during online download
Doubly Linked List Review - We are writing this code
UNIT-3 LINKED LIST.
Objectives In this lesson, you will learn to: Define stacks
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
Lecture 22 Binary Search Trees Chapter 10 of textbook
Algorithms and Data Structures
Dynamic Memory CSCE 121 J. Michael Moore.
Linked list insertion Head. Linked list insertion Head.
Linked lists Motivation: we can make arrays, but their functionality is slightly limited and can be difficult to work with Biggest issue: size management.
Programmazione I a.a. 2017/2018.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Introduction to Linked Lists
Recursion & Linked Lists
Arrays and Linked Lists
Chapter 18: Linked Lists.
Linked List Intro CSCE 121 J. Michael Moore.
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Summary Array List.
Linked List Insert After
Pushing at the back.
Sorted Linked List A linked list is a data structure that consists of a sequence of data records such that in each record there is a field that contains.
Linked List Configurations
Linked Lists.
Data Structures & Algorithms
CSC 143 Binary Search Trees.
Heaps By JJ Shepherd.
Linked List Functions.
Linked List Recursion.
Linked Lists.
Queues: Implemented using Linked Lists
Stacks, Queues, and Deques
Linked List Intro CSCE 121.
Traversing a Linked List
Dynamic Memory CSCE 121.
Linked List Insert After
Abstract Data Types Stacks CSCI 240
Lecture-Hashing.
Presentation transcript:

Linked List Configurations CSCE 121

General Representation Head Tail Head should always point to the first item or nullptr if the list is empty. Tail should always point to the last item or nullptr if the list is empty. … 11 3 8 Requirments  “invariants” Any time you add / delete nodes, you need to ensure that these requirements are still true!

General Representation Head Tail Useful to think about different configurations Especially when adding and deleting nodes … 11 3 8

Empty List Head Tail If adding a node Don’t forget to update head and tail to point to the new node! Head Tail

How to know if the list is empty? Recall that the symbol used above represents nullptr. So if head (or tail) equals nullptr, then the list is empty. Of course you have to ensure you are keeping head and tail updated appropriately. Head Tail

11 Single item on the list Head Tail If deleting a node Don’t forget to update head and tail to nullptr! If adding a node Don’t forget to update head (or tail, depending on the end to which the element is added). 11

How to know if only one item on list? Head Tail Recall that arrows represent memory addresses, so if two arrows point to the same thing, they have the same address / value. If head and tail are equal, then either the list is empty they point to the same node, i.e. the only item in the list. 11

… 11 3 8 Don’t Forget! Head Tail Head should always point to the first item or nullptr if the list is empty. Tail should always point to the last item or nullptr if the list is empty. … 11 3 8 Any time you add / delete nodes, you need to ensure that these requirements are still true!

Wrapper Make the linked list a class. Good for organizing the linked list. Head and Tail are private data members. Various methods will be member functions. We’ll do an extended examples where aspects of a linked list are done as labworks.