Lecture 14 Linked Lists 14-1 Richard Gesick. Linked Lists Dynamic data structures can grow and shrink at execution time. A linked list is a linear collection.

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

Linear Lists – Linked List Representation
M180: Data Structures & Algorithms in Java
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.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures.
Topic 11 Linked Lists -Joel Spolsky
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Summary of lectures (1 to 11)
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
 2006 Pearson Education, Inc. All rights reserved Data Structures.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Arrays and Linked Lists "All the kids who did great in high school writing pong games in BASIC for their Apple II would get to college, take CompSci 101,
Introduction to Data Structures Systems Programming.
(1 - 1) Introduction to C Data Structures & Abstract Data Types Instructor - Andrew S. O’Fallon CptS 122 (August 26, 2015) Washington State University.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
CS 307 Fundamentals of Computer ScienceLinked Lists 1 Topic 14 Linked Lists "All the kids who did great in high school writing pong games in BASIC for.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
Self-Referential Classes A Self-referential class is a class that contains a reference to an object that has the same class type. –A self-referential class.
Introduction to Data Structures Systems Programming Concepts.
1 Chapter 17 – Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
Linked List Chapter Data Abstraction separates the logical properties of a data type from its implementation LOGICAL PROPERTIES – What are the.
1 Linked Structures, LinkedSet References as Links Linear Linked Lists and Non-linear Structures Managing Linked Lists Data Encapsulation Separate from.
COSC 1P03 Data Structures and Abstraction 5.1 Linear Linked Structures A bank is a place where they lend you an umbrella in fair weather and ask for it.
Subject Name : Data Structure Using C Title : Linked Lists
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Introduction Dynamic Data Structures Grow and shrink at execution time Linked lists are dynamic structures where data items are “linked up in a chain”
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Linked Lists Linked Lists Dale.
 Array is a data structure were elements are stored in consecutive memory location.in the array once the memory is allocated.it cannot be extend any more.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
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:
Lecture 16 Linked Lists. In this lecture Fundamentals Applications Memory Allocation Creating a List Inserting Nodes.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
UNIT-II Topics to be covered Singly linked list Circular linked list
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Templates Linked Lists.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
(1-3) Basics of a Linked List I Instructor - Andrew S. O’Fallon CptS 122 (June 9, 2016) Washington State University.
Lecture 6 of Computer Science II
Data Structure By Amee Trivedi.
Chapter 12 – Data Structures
Dynamic Allocation Review Structure and list processing
5.13 Recursion Recursive functions Functions that call themselves
UNIT – I Linked Lists.
Data Structure Interview Question and Answers
Review Deleting an Element from a Linked List Deletion involves:
12 C Data Structures.
Chapter 22 Custom Generic Data Structures
Linked Lists head One downside of arrays is that they have a fixed size. To solve this problem of fixed size, we’ll relax the constraint that the.
Introduction to Data Structures
Arrays and Linked Lists
Lecture 20 Linked Lists Richard Gesick.
Linked Lists.
Review & Lab assignments
Chapter 17: Linked Lists.
Lecture 14 Linked Lists CSE /26/2018.
Data Structures & Algorithms
(1 - 2) Introduction to C Data Structures & Abstract Data Types
CS148 Introduction to Programming II
CMPT 225 Lecture 5 – linked list.
Presentation transcript:

Lecture 14 Linked Lists 14-1 Richard Gesick

Linked Lists Dynamic data structures can grow and shrink at execution time. A linked list is a linear collection (i.e., a sequence) of nodes, connected by reference links (“chained together”). It can be singly or doubly linked A linked list is appropriate when the number of data elements is unpredictable. Linked lists become full only when the system has insufficient memory. 14-2

Nodes A self-referential class contains a member that refers to an object of the same class type. In the class declaration Next references an object of type Node, an object of the same type being declared. Next is referred to as a link. class Node { public string data; public Node next ; } 14-3

Common tasks include: Inserting to the front Inserting to the end Inserting in between the front/end Deleting Searching Sorting Each of these tasks takes different amounts of time depending upon how the linked list is implemented 14-4

A Linked List A backslash indicates a null link. Not setting the link in the last node of a list to null is a logic error. 14-5

Inserting at the front Method InsertFront places a new node at the front of the list through the following process: 1.Create a new Node 2.Assign new data to Node data 3.Assign the current head node’s address/pointer to the new Node 4.Set the head node’s address/pointer to the new Node 14-6