Linked List. LINKED LIST Link is collection of similar type of elements. There are two ways of maintaining a list in memory. The first way is store the.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Lists CS 3358.
Linked Lists.
DATA STRUCTURES USING C++ Chapter 5
Linked Lists Linked Lists Representation Traversing a Linked List
CHP-5 LinkedList.
Singly Linked List BTECH, EE KAZIRANGA UNIVERSITY.
1 DATA STRUCTURES. 2 LINKED LIST 3 PROS Dynamic in nature, so grow and shrink in size during execution Efficient memory utilization Insertion can be.
Review Learn about linked lists
Data Structures: A Pseudocode Approach with C
Data Structures & Algorithms
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
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.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Data Structures Using C++ 2E
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
UNIT-2. Singly Linked List Doubly Linked List Circular Linked List Representing Stack with Linked List. Representing Queue with Linked List.
Reference: Vinu V Das, Principles of Data Structures using C and C++
2 Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during insertions and deletions Linked list is able to.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 4: Linked Lists Data Abstraction & Problem Solving with.
Implementation of Linked List For more notes and topics visit: eITnotes.com.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Lists 1. Introduction Data: A finite sequence of data items. Operations: Construction: Create an empty list Empty: Check if list is empty Insert: Add.
D ATA S TRUCTURE Ali Abdul Karem Habib MSc.IT. P OINTER A pointer is a variable which represents the location of a data item. We can have a pointer to.
Lists II. List ADT When using an array-based implementation of the List ADT we encounter two problems; 1. Overflow 2. Wasted Space These limitations are.
A first look an ADTs Solving a problem involves processing data, and an important part of the solution is the careful organization of the data In order.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
Dynamic Array. An Array-Based Implementation - Summary Good things:  Fast, random access of elements  Very memory efficient, very little memory is required.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Subject Name : Data Structure Using C Title : Linked Lists
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,
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
 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.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
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.
Data Structure & Algorithms
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.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
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.
  A linked list is a collection of components called nodes  Every node (except the last one) contains the address of the next node  The address of.
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.
LINKED LISTS.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Linked List ADT used to store information in a list
Unit – I Lists.
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
Linked Lists Chapter 6 Section 6.4 – 6.6
Review Deleting an Element from a Linked List Deletion involves:
UNIT-3 LINKED LIST.
Linked lists.
Programmazione I a.a. 2017/2018.
Lists.
Arrays and Linked Lists
Chapter 18: Linked Lists.
Review & Lab assignments
Chapter 17: Linked Lists.
Linked lists.
BY PROF. IRSHAD AHMAD LONE.
Chapter 9 Linked Lists.
Presentation transcript:

Linked List

LINKED LIST Link is collection of similar type of elements. There are two ways of maintaining a list in memory. The first way is store the elements of the list in an array but array have some limitation and disadvantages. The second way of maintaining a list in memory is through linked list.

TYPE OF LINKED LIST SINGLE LINKED LIST DOUBLY LINKED LIST CIRCULAR LINKED LIST

1.SINGLE LINKED LIST A single Link list is made up of nodes where each node has two parts, The first one is the info part that contains the actual data of list and second one of link part that points to next node of the list. INFO PARTLINK

SINGLE LINKED LIST The beginning of the list is made by a special pointer named START. This pointer points to the first node of the list. The link part of each node points to the next node in the list but the link part of last node has no next node to point to, so it is made NULL.

SINGLE LINKED LIST START NODE ANODE BNODE CNODE D NULL 350

ADVANTAGES AND DISADVANTAGES Linked list have many advantages and some of them are: 1. Linked list are dynamic data structure. That is, they can grow or shrink during the execution of a program. 2. Efficient memory utilization: In linked list (or dynamic) representation, memory is not pre- allocated. Memory is allocated whenever it is required. And it is deallocated (or removed) when it is not needed.

ADVANTAGES AND DISADVANTAGES 3. Insertion and deletion are easier and efficient. Linked list provides flexibility in inserting a data item at a specified position and deletion of a data item from the given position. 4. Many complex applications can be easily carried out with linked list. Linked list has following disadvantages 1. More memory: to store an integer number, a node with integer data and address field is allocated. That is more memory space is needed. 2. Access to an arbitrary data item is little bit cumbersome and also time consuming.

OPERATION ON A SINGLE LINKED LIST 1.TRAVERSAL OF LINKED LIST 2.SEARCHING AN ELEMENTS 3.INSERATION OF AN ELEMENT 4.DELETION OF AN ELEMENT 5.CREATION OF A LINKED LIST 6.REVERSAL OF A LINKED LIST

1.TRAVERSING A SINGLE LINKED LIST Traversal means visiting each node,starting from first node till reach the last node. For this we will take a structure pointer p which will point to the node that is currently being visited. Initially we have to visit the first node so p is assigned the value of start. p=start Now p point to the first node of linked list. We can access the info part of first node by writing. p->info. Now we have to shifting the pointer p forward so that it points to next node. This can be done by assigning the address of next node to p as… p=p->link; Now p has the address of the next node. Similarly we can visting each node of linked list through this assignment until p has NULL, which is link part value of last element. while (p!=NULL) { Printf(“%d”,p->info); P=p->link; }

START NODE ANODE BNODE CNODE D NULL 350

FUNCTION DISPLAY () The follwing function display() display the contents of the linked list. void display() { struct node * p If (start ==NULL) { Printf(“lists is empty\n”); } P= strat; Printf(“list is:\n”); While (p!=NULL) { Printf(“%d”,p->info); } Printf(“\n\n”); }/* END OD DISPLAY()*/

FUNCTION COUNT() The following function count() finds out number of elements of linked list. void count() { struct node * p Int cnt=0; While (p!=NULL) { P=p->link; Cnt++; } Printf(“\n number of elements are %d”,cnt); }/* END OF COUNT()*/

2.SEARCHING IN A LINKED LIST For searching an elements, we traverse the linked list and while traversing we compare the info part to each elements with the given elements to be searched.

FUNCTION SEARCH() Void search(struct node * start, int item) { struct node * p= strat; int pos =1; While(p!=NULL) { if (p->info==item) { printf(“item %d found at postion %d\n”,item,pos); } p = p->link; pos ++; } printf(“item %d not found in lidt\n”,item); }/* End of search ()*/

3.INSERTION IN A SINGLE LINKED LIST There can be four cases while inserting a node in a linked list. 1.Insertion at the beginning 2. Insertion at an empty list 3. Insertion at the end 4.Insertion at b/w the list node