LINKED LIST Dr. T. Kokilavani Assistant Professor

Slides:



Advertisements
Similar presentations
Linked Lists Linked Lists Representation Traversing a Linked List
Advertisements

CHP-5 LinkedList.
Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Ceng-112 Data Structures I Chapter 5 Queues.
M180: Data Structures & Algorithms in Java
Foundation of Computing Systems Lecture 2 Linked Lists.
Data Structures: A Pseudocode Approach with C
COSC 1P03 Data Structures and Abstraction 5.1 Linear Linked Structures.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Memory Management A memory manager should take care of allocating memory when needed by programs release memory that is no longer used to the heap. Memory.
Simulated Pointers Limitations Of Java Pointers May be used for internal data structures only. Data structure backup requires serialization and deserialization.
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.
Memory Management -Memory allocation -Garbage collection.
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,
1 Linked Lists (Lec 6). 2  Introduction  Singly Linked Lists  Circularly Linked Lists  Doubly Linked Lists  Multiply Linked Lists  Applications.
Chapter Lists Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Tree.
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.
Simulated Pointers Limitations Of C++ Pointers May be used for internal data structures only. Data structure backup requires serialization and deserialization.
1 CSC 211 Data Structures Lecture 11 Dr. Iftikhar Azim Niaz 1.
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.
Data Structure & Algorithms
Array 10 GB Hard Disk 2 GB 4 GB2 GB 3 GB DATA 4 GB Free Store data in the form of Array (Continuous memory locations) Solution-1: No Solution. Memory Insufficient.
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.
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.
1 Data Organization Example 1: Heap storage management Maintain a sequence of free chunks of memory Find an appropriate chunk when allocation is requested.
STACKS & QUEUES for CLASS XII ( C++).
Lecture 6 of Computer Science II
Data Structures Using C, 2e
Data Structure By Amee Trivedi.
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
Data Structure Interview Question and Answers
Review Deleting an Element from a Linked List Deletion involves:
Interview, Viva and Basic Questions of Data Structures
CS522 Advanced database Systems
Data Structure and Algorithms
Prepared by, Jesmin Akhter, Lecturer, IIT, JU
UNIT-3 LINKED LIST.
Chapter 11: File System Implementation
Data Structures Interview / VIVA Questions and Answers
CSCE 210 Data Structures and Algorithms
LINKED LISTS CSCD Linked Lists.
Circular Buffers, Linked Lists
Data Structures and Analysis (COMP 410)
Chapters 17 & 18 6e, 13 & 14 5e: Design/Storage/Index
Simulated Pointers.
DATA STRUCTURE QUEUE.
Arrays and Linked Lists
Chapter 11: File System Implementation
Simulated Pointers.
Linked Lists.
11-3 LINKED LISTS A linked list is a collection of data in which each element contains the location of the next element—that is, each element contains.
CS212D: Data Structures Week 5-6 Linked List.
Advance Database System
General Trees A general tree T is a finite set of zero or more nodes such that there is one designated node r, called the root of T, and the remaining.
Linked Lists.
By Yogesh Neopaney Assistant Professor Department of Computer Science
Data Structures & Algorithms
File Organization.
Chapter 11: File System Implementation
Data Structures and Algorithms Memory allocation and Dynamic Array
Array operations Dr. T. Kokilavani Assistant Professor
Mr. M. D. Jamadar Assistant Professor
Presentation transcript:

LINKED LIST Dr. T. Kokilavani Assistant Professor Department of Computer Science St. Joseph’s College Trichy - 620002 Data Structures and Algorithms, Dr.T.Kokilavani, SJC

Linked List In arrays, block of memory that is required for the array should be allocated before use. Once memory is located it cannot be extended any more. So array is called static data structure. Linked list is called dynamic data structure, because amount of memory required can be varied during its use. In linked list, adjacency between the elements are maintained by means of links or pointers. A link or pointer is the address (memory location) of the subsequent element. An element in a linked list is called node. A node consists of two fields: DATA (to store the actual information) and LINK (to point to the next node). Data Structures and Algorithms, Dr.T.Kokilavani, SJC

Definition A linked list is an ordered collection of finite, homogenous data elements called nodes where the linear order is maintained by means of links or pointers. Linked list can be classified into three major groups: single linked list circular linked list double linked list Data Structures and Algorithms, Dr.T.Kokilavani, SJC

Single Linked List In a single linked list each node contains only one link which points the subsequent node in the list. This figure shows a linked list with 6 nodes. N1, N2, …., N6 are the constituent nodes in the list. Header is an empty node (data content NULL) and only used to store a pointer to the first node N1. Starting from the first node one can reach to the last node whose link field does not contain any address rather than a null value. In a single linked list one can move from left to right only, that is why it is called one way list. Data Structures and Algorithms, Dr.T.Kokilavani, SJC

Representation of a linked list in memory There are two ways to represent a linked list in memory: Static representation using array Dynamic representation using free pool of storage Static representation of a single linked list maintains two arrays: One array for data and other for links. Data Structures and Algorithms, Dr.T.Kokilavani, SJC

Dynamic representation In this method, there is a memory bank (nothing but a collection of free spaces) and a memory manager ( a program). During the creation of linked list, whenever a node is required the request is placed to the memory manager which will then search the memory bank for the block requested and if found grants a desired block to the caller. Another program called garbage collector returns the unused node to the memory bank, whenever a node is no more in use. This is called dynamic memory management. Dynamic representation of linked list uses the dynamic memory management policy Data Structures and Algorithms, Dr.T.Kokilavani, SJC

Dynamic representation A list of available memory space’s pointer is stored in AVAIL. If there is a request for node, the AVAIL is searched for the block of right size. If AVAIL is null or the block of desired size is not found memory manager will return a message accordingly. If the block is found then let it be XY. Then memory manager will return the pointer of XY to a temporary buffer, NEW. The new node XY then can be inserted at any position in the linked list by changing the pointers of the concerned nodes. Data Structures and Algorithms, Dr.T.Kokilavani, SJC

This figure shows how a node is to be returned to the memory bank. The node XY is inserted at the end and change of pointers are shown by the dotted arrows. This figure shows how a node is to be returned to the memory bank. Data Structures and Algorithms, Dr.T.Kokilavani, SJC