Single Linked Lists Objectives In this lesson, you will learn to: *Define single linked list *Identify the following types of linked lists: Single linked.

Slides:



Advertisements
Similar presentations
Linked Lists.
Advertisements

Linked Lists Mohammed Almashat CS /03/2006.
Linked Lists.
CHP-5 LinkedList.
Data Structure Lecture-5
Introduction to Database Systems1 Records and Files Storage Technology: Topic 3.
M180: Data Structures & Algorithms in Java
Review Learn about linked lists
Data Structures: A Pseudocode Approach with C
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
Rossella Lau Lecture 3, DCO20105, Semester A, DCO Data structures and algorithms  Lecture 3: Basics of Linked List  C++ pointer revision.
Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
Data Structures Using C++ 2E
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
DAY 16: ACCESS CHAPTER 2 Tazin Afrin October 10,
Reference: Vinu V Das, Principles of Data Structures using C and C++
Implementation of Linked List For more notes and topics visit: eITnotes.com.
SIMULATED UNIX FILE SYSTEM Implementation in C Tarek Youssef Bipanjit Sihra.
Data Structures Using Java1 Chapter 4 Linked Lists.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Linked Lists part 2 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
3 / 12 Databases MIS105 Lec13 Irfan Ahmed Ilyas CHAPTER Prepared By:
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 17: Linked Lists.
Linked Lists part 1 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
CS2006- Data Structures I Chapter 5 Linked Lists III.
1. Circular Linked List In a circular linked list, the last node contains a pointer to the first node of the list. In a circular linked list,
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists (part 3)
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
Linked Lists (continued). Maintaining Order Creating an ordered list 3 Baltimore head Rome Seattle Toronto  (1) Insert node containing (reference to.
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:
1 Linked List. Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion.
1 Linked List. 2 List A list refers to a sequence of data items  Example: An array The array index is used for accessing and manipulation of array elements.
1 Chapter 4 Unordered List. 2 Learning Objectives ● Describe the properties of an unordered list. ● Study sequential search and analyze its worst- case.
Lists List Implementations. 2 Linked List Review Recall from CMSC 201 –“A linked list is a linear collection of self- referential structures, called nodes,
CHAPTER 51 LINKED LISTS. Introduction link list is a linear array collection of data elements called nodes, where the linear order is given by means of.
Linked Lists Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Templates Linked Lists.
LINKED LISTS.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part R2. Elementary Data Structures.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
Data Structures Using C, 2e
Module 11: File Structure
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
UNIT – I Linked Lists.
Data Structure Interview Question and Answers
Review Deleting an Element from a Linked List Deletion involves:
Data Structure and Algorithms
Lecture - 6 On Data Structures
UNIT-3 LINKED LIST.
Linked lists.
Data Structures Interview / VIVA Questions and Answers
Lecture 22 Binary Search Trees Chapter 10 of textbook
External Methods Chapter 15 (continued)
Tonga Institute of Higher Education
CSCE 210 Data Structures and Algorithms
LINKED LISTS CSCD Linked Lists.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Linked Lists Chapter 4.
Linked List.
Linked lists.
LINEAR DATA STRUCTURES
Presentation transcript:

Single Linked Lists Objectives In this lesson, you will learn to: *Define single linked list *Identify the following types of linked lists: Single linked list Circular linked list Double linked list *Implement the following operations on single linked list: 3Inserting nodes

Single Linked Lists Objectives (Contd.) 3Traversing a linked list 3Querying information 3Deleting nodes 3Sorting lists

Single Linked Lists Linked List *Is a chain of objects in which each object consists of the data and a pointer that stores the address of the next logical object in the list *Types of linked lists: 3Single linked list 3Circular linked list 3Double linked list

Single Linked Lists Single Linked List *Is a chain of structures in which each structure consists of data and a pointer START INFONEXT INFO NEXT NULL

Single Linked Lists Circular Linked List  Has the START pointer pointing to the first node and the last pointer also pointing to the first node START INFONEXT INFO NEXTINFONEXT

Single Linked Lists Double Linked List  Has 3 parts: the INFO, NEXT pointer, and PREV pointer *Is also called a two-way list START NEXTINFO NEXTPREV LAST PREV NULL NEXTPREVINFO NULL

Single Linked Lists Operations on Lists Are: *Insertion *Traversal *Deletion *Modification *Sorting

Single Linked Lists Applications of Lists Are: *Word processing applications *Index maintenance in a file-based database package *Maintenance of linked lists for data files that have read-write overhead

Single Linked Lists INFO NEXT START NULL Inserting Nodes at the Beginning of a Single Linked List Existing Links on the list Links after inserting the new node

Single Linked Lists Inserting Nodes at the Beginning of a Single Linked List (Contd.) Requires to: *Check whether or not the list exists  Check whether the user supplied string is lesser than the INFO in the first node

Single Linked Lists Inserting a Node in the Middle or at the End of a Linked List Tom NEXT prev Existing Links on the list Links after inserting the new node NULL Ann NEXT currSTART NEXT

Single Linked Lists Inserting a Node in the Middle or at the End of a Linked List (Contd.) Requires to: *Allocate the memory for the new node  Position the pointer prev on the node after which the new node is to be inserted and the pointer curr to be positioned on the node before which the new node is to be inserted.  Complete the link by making the NEXT of the previous node point to the new node

Single Linked Lists Traversing a Linked List *Helps to display the contents of a list *Is done by following the listed steps : 1. Set a temporary pointer, temp, to START 2. Display the INFO part of the node pointed by temp 3. Advance the pointer, temp, so that it points to the next node 4. Repeat steps 2 and 3 until temp is not equal to NULL

Single Linked Lists Problem Statement 11.D.1 Create an application that accepts the names of an unknown number of customers and displays them in alphabetical order.

Single Linked Lists Querying Information  Is done by following the listed steps : 1. The pointer CURRENT, is positioned at the node that contains the name matching the supplied string 2. The pointer PRECEDE, is positioned at the node that is just before the node pointed by CURRENT 3. If the pointer CURRENT contains NULL, it means that the entire list was traversed without finding the specified string

Single Linked Lists Deleting Nodes *Can be done in two forms: 3Logical deletion of the node from the linked list (de- linking the node from the list)  Physical deletion of the node to free the memory occupied by the node (the delete operator used to free the memory occupied by the node)

Single Linked Lists Deleting Nodes (Contd.) Is done by following the listed steps: 1. Check whether or not the supplied string is present in any of the nodes 2. Position the pointer CURRENT at the node to be deleted 3. Position the pointer PRECEDE at the node that is just before the node pointed by CURRENT 4. Reposition START if the node that was delinked was the first node in the list 5. Delete the memory for the CURRENT node

Single Linked Lists Problem Statement 11.D.2 Modify the above application to allow deletion of unwanted customer records.

Single Linked Lists Problem Statement 11.P.1 Modify the above application such that along with the name of the customer his address and customer code is also stored and on querying the record based on customer code, you can view customer details.

Single Linked Lists Summary In this lesson, you learned that: *A linked list is a chain of objects in which each object consists of data and a pointer that stores the address (link) of the next logical object in the list *The main advantages of linked lists are: 3Memory is allocated whenever required 3Inserting and deleting can be handled efficiently, without having to restructure the list

Single Linked Lists Summary (Contd.) *Linked lists can be of three types: 3A single linked list is a chain of structures in which each structure consists of data as well as a pointer, called the node  A circular linked list has the START pointer pointing to the first node and the last node contains the address of the starting node  A double linked list is also called a two way list, which has a START pointer pointing to the first node and the pointer NEXT and PREV pointing to the next and previous node

Single Linked Lists Summary (Contd.) *Each node has two parts: 3The first part contains the information (the INFO) 3The second part is a pointer, which contains the address of the subsequent node (the NEXT) *The different operations that can be performed on linked lists are: 3Insertion -involves adding a new node to an existing linked list or creating a new linked list if one does not already exist

Single Linked Lists Summary (Contd.) 3Traversal - involves moving from one node to another using pointers to display the contents of a node in an existing list 3Deletion - involves deleting an existing node from the linked list 3Modification - involves changing the existing information contained in the node to reflect the latest status 3Sorting - involves rearranging the order of the nodes in the list

Single Linked Lists Summary (Contd.) *The three classes which make a complete linked list are as follows:  A class to represent the data or INFO part of the node  The Node structure, which will contain an object of the built-in data class called INFO and a pointer to a Node object called NEXT  The List class that will contain the starting pointer to a Node object

Single Linked Lists Summary (Contd.) *The insertion and deletion of a node can be performed at three different levels: 3At the beginning of the list 3In the middle of the list 3At the end of the list