Linked Lists Mohammed Almashat CS 561 26/03/2006.

Slides:



Advertisements
Similar presentations
Linked Lists Geletaw S..
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 1.
Chapter 3: Linked List Tutor: Angie Hui
Linked List: Traversal Insertion Deletion. Linked List Traversal LB.
Lists CS 3358.
Chapter 17 Linked Lists.
Stacks, Queues, and Linked Lists
Linked Lists.
Linear Lists – Linked List Representation
Linked Lists Linked Lists Representation Traversing a Linked List
Data Structure Lecture-5
Data Structure Lecture-3 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Linked Lists... An introduction to creating dynamic data structures.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 17: Linked Lists.
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
Class 3: Linked Lists. cis 335 Fall 2001 Barry Cohen What is a linked list? n A linked list is an ordered series of ‘nodes’ n Each node contains some.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
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.
Summary of lectures (1 to 11)
Variations of Linked Lists CS 308 – Data Structures.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Implementation of Linked List For more notes and topics visit: eITnotes.com.
Linked Lists part 2 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
Today’s Agenda  Linked Lists  Double ended Linked Lists  Doubly Linked Lists CS2336: Computer Science II.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Week 4 - Monday.  What did we talk about last time?  Queues  Implementing queues with circular arrays.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
The List ADT A sequence of zero or more elements A 1, A 2, A 3, … A N-1 N: length of the list A 1 : first element A N-1 : last element A i : position i.
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.
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
Linked Lists. Introduction In linked list each item is embedded in a link Each item has two parts – Data – Pointer to the next item in the list Insert,
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
Week 4 - Friday.  What did we talk about last time?  Continued doubly linked list implementation  Linked lists with iterators.
 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.
CS162 - Topic #7 Lecture: Dynamic Data Structures –Review of pointers and the new operator –Introduction to Linked Lists –Begin walking thru examples of.
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:
1 Linked List. Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion.
CS 46B: Introduction to Data Structures July 23 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
Data Structure & Algorithms
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
Single Linked Lists Objectives In this lesson, you will learn to: *Define single linked list *Identify the following types of linked lists: Single linked.
Doubly Linked List Exercises Sometimes it is useful to have a linked list with pointers to both the next and previous nodes. This is called a doubly linked.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
1 CMPT 117 Linked Lists (singly linked). 2 Problems with arrays  When an element is deleted from or inserted into an array, the rest of the array has.
CS32 Discussion Section 1B Week 3 TA: Hao Yu (Cody)
Lists List Implementations. 2 Linked List Review Recall from CMSC 201 –“A linked list is a linear collection of self- referential structures, called nodes,
Linked Lists Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
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.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
CS162 - Topic #9 Lecture: Dynamic Data Structures –Deallocating all nodes in a LLL –Inserting nodes into sorted order Programming Assignment Questions.
Programming Circular Linked List.
UNIT – I Linked Lists.
Linked Lists.
Linked lists.
Sequences 9/18/ :20 PM C201: Linked List.
Linked Lists Chapter 4.
Chapter 17: Linked Lists.
CS148 Introduction to Programming II
CS148 Introduction to Programming II
Linked lists.
Presentation transcript:

Linked Lists Mohammed Almashat CS /03/2006

Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion

Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion

Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages

Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages

Lists and arrays Lists:

Lists and arrays Arrays: {Size of the following array is = 4} Index0123 Value445963

Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages

Nodes and pointers

Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages

Single linked lists

Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages

Double Linked Lists

Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages

Circular Lists

Introduction Definitions –Lists and arrays –Nodes and pointers –Single Linked Lists –Double Linked Lists –Circular Lists Advantages

The Linked List advantages are collected because of the array disadvantages, array disadvantages are: 1.Array Size 2.Memory allocation 3.Insertion and Deletion

Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion

Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list

Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list

Insertion at the top Steps: Create a Node Set the node data Values Connect the pointers

Insertion Description Follow the previous steps and we get head // head 93 Step 1 Step 2 Step 3

Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list

Insertion at the end Steps: Create a Node Set the node data Values Connect the pointers

Insertion Description Follow the previous steps and we get head // Step 1 Step 2 Step 3

Insertion Description Insertion at the top of the list Insertion at the end of the list Insertion in the middle of the list

Insertion in the middle Steps: Create a Node Set the node data Values Break pointer connection Re-connect the pointers

Insertion Description Step 1 Step 2 Step 3 Step 4

Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion

Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list

Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list

Deleting from the top Steps Break the pointer connection Re-connect the nodes Delete the node

Deletion Description 417 head head head 42

Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list

Deleting from the end Steps Break the pointer connection Set previous node pointer to NULL Delete the node

Deletion Description 417 head head head

Deletion Description Deleting from the top of the list Deleting from the end of the list Deleting from the middle of the list

Deleting from the Middle Steps Set previous Node pointer to next node Break Node pointer connection Delete the node

Deletion Description head 417 head 42 4 head 42

Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion

Basic Node Implementation The following code is written in C++: Struct Node { int data; //any type of data could be another struct Node *next; //this is an important piece of code pointer };

Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion