You are on page 1of 20

CSE 1315

Data Structure
Lecture-11

Prithwiraj Bhattacharjee
B.Sc in CSE at SUST
Adjunct Faculty, Dept. of CSE
Leading University, Sylhet
Overflow and Underflow
● The free storage list contains the available list of memory address
● If it is empty and we want to insert new node
○ OVERFLOW
● We denote it by AVAIL = NULL
● If START value is NULL and we want to delete any node
○ UNDERFLOW
Insertion Into a Linked List
Insertion Into a Linked List
● LIST(INFO, LINK, START, AVAIL)
Insertion Into a Linked List

● NEW = AVAIL, AVAIL=LINK[AVAIL]


● INFO[NEW]=ITEM
● NODE CREATION
Inserting at the Beginning of the LIST
Inserting at the Beginning of the LIST
Inserting after a Given node
● Let A is a node
● Location of A is denoted by LOC
● When LOC = NULL it is a empty list
● You want to insert an ITEM
○ After A node if LOC contains A node’s address
○ Or ITEM is the first node if LOC=NULL
● If LOC = NULL process is as before stated
● If LOC = A node address and if B is the next node after A then
○ LINK[NEW] = LINK[LOC]
○ LINK[LOC] = NEW
Inserting after a Given node
Inserting into a sorted Linked List
Inserting into a sorted Linked List
Deletion from a Linked List
Deletion from a Linked List
● LIST(INFO, LINK, START, AVAIL)
Deletion from a Linked List
● LIST(INFO, LINK, START, AVAIL)

● LINK[LOC] = AVAIL, AVAIL = LOC


Deletion from a Linked List
● LIST(INFO, LINK, START, AVAIL)

● LINK[LOC] = AVAIL, AVAIL = LOC


Deleting a node following a given node

● START = LINK[START]
Deleting a node following a given node

● LOCP = ?
● LOC = ?
Deleting a node following a given node
Deleting the node With a given ITEM
Deleting the node With a given ITEM

You might also like