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.
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.
CS 106 Introduction to Computer Science I 12 / 06 / 2006 Instructor: Michael Eckmann.
CS102--Object Oriented Programming Lecture 17: – Linked Lists Copyright © 2008 Xiaoyan Li.
CS 206 Introduction to Computer Science II 11 / 04 / 2009 Instructor: Michael Eckmann.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
CS 106 Introduction to Computer Science I 04 / 25 / 2008 Instructor: Michael Eckmann.
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.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
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.
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: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
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.
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.
Tree Representations Mathematical structure An edge A leaf The root A node.
Chapter 16: Linked Lists.
CSE 1342 Programming Concepts
Topic 2: binary Trees COMP2003J: Data Structures and Algorithms 2
C++ Programming:. Program Design Including
Introduction to Linked Lists
CSCI-255 LinkedList.
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
Lecture 22 Binary Search Trees Chapter 10 of textbook
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
Linked List Intro CSCE 121 J. Michael Moore.
Data Representation Bits
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Summary Array List.
Linked List Insert After
Pushing at the back.
Batch Parties Changes.
Essential Class Operations
Linked Lists.
Data Structures & Algorithms
CSC 143 Binary Search Trees.
Linked List Functions.
Linked List Recursion.
Linked Lists.
Queues: Implemented using Linked Lists
Bingo Example: Design (Random Distinct Numbers Algorithm)
Stacks, Queues, and Deques
Linked List Configurations
Linked List Intro CSCE 121.
Traversing a Linked List
Instructor: Dr. Michael Geiger Spring 2019 Lecture 23: Exam 2 Preview
Dynamic Memory CSCE 121.
Linked List Insert After
Abstract Data Types Stacks CSCI 240
Lecture-Hashing.
Presentation transcript:

Linked List Configurations CSCE 121 J. Michael Moore

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 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. 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.