SlideShare a Scribd company logo
1 of 15
Creating a Linked list :
Algorithm :
Create first node and assign the address of the first node to the
pointer ‘start’.
Step : 1 start =getnode( );
Use another pointer to store the address of the first node, called
CURRPTR
Step : 2 currptr=Start;
Accept the item and store it in the INFO field of the node
Step : 3 info[currptr ]= item;
Accept the Choice from the keyboard whether to create another node
or not
Step : 4 if ( choice = ‘Y’)
goto step 5
else
goto step 6
If choice is ‘Y’ to create another node
Step : 5 i) Newnode = getnode( );
Newnode which contains the address of the newly created node
ii) link[currptr]=Newnode;
Making a link between the original last node and present newnode
iii) currptr=Newnode;
Address of the Newnode is assigned to the original newnode
iv) info[currptr]=item;
Accepting the item and storing it in the info field of currptr
go to step 4
If choice is ‘N’ to make the LINK field of the last node to NULL
Step : 6 link [currptr] = NULL and
Exit
Step : 7 return
• Traversing a linked list :
Algorithm:
Step 1 : Is linked list is empty
if ( start ==NULL)
display (“ linked list is empty “);
exit( )
Step 2 : Assign start value to CURRPTR
currptr=start;
Step 3 : Repeat while(currptr!=NULL)
Process info[currptr]
Step 4 : currptr=link[currptr] /* moving the currptr from one
node to the next node */
Step 5 : Exit
• Algorithm for Displaying a list :
• first check list is empty or not
• Step 1 : if ( start == NULL)
– Write (“ list is Empty”)
– return;
Store the Address of first node in another pointer CURRPTR
• Step 2 : set currptr = start;
• Step 3 : Repeat step4 and step5 while ( currptr !=NULL)
• Display items one-by-one from first node until Currptr becomes
NULL
• Step 4 : display ( info[currptr]);
After the display of this element ,Currptr should point to the next node
• Step 5 : currptr=link[currptr];
• Step 6 : Exit
• Insert operation at the beginning :
• Algorithm :
• Creating a node that is to be inserted
• step 1 : Newnode =getnode( );
• Enter the item into the Info field of the New node
• step 2 : info [Newnode]= item;
• Assign the start value to the LINK part of the inserted node(New
node).
• It makes a link from ‘New node’ to the previous first node.
• Now start and New node points to the original first node of the list.
• It makes link between start and Newnode.
• step 3 : link [Newnode]=start;
• step 4 : start = Newnode;
Exit;
• Algorithm : insert operation at end
Step 1 : if list is empty
if ( start == NULL)
insert at the beginning
exit( )
end if
Step 2 : currptr = start;
Traverse the list to obtain the last node address
Step 3 : while (link [currptr]! = NULL)
currptr = link [ currptr]
end while
Create a newnode and enter the accepted ITEM into its INFO fields
Step 4 : Newnode =getnode( );
Newnode -> info =item;
Make a link between Currptr(last node) and New node
Step 5 : link [currptr] = Newnode;
Step 6 : link [Newnode] = NULL
Step 7 : Exit
• Algorithm for Inserting at certain position :
Step 1: Set CURRPTR to Start
Currptr=Start
Step 2: If the item is to be inserted at 1st position
if (pos==1)
Algorithm for inserting at beginning
Else go to step 3
Step 3: If the item to inserted at some position other than 1st position
for ( i=0; i < pos-2;i++)
{
Currptr= LINK[Currptr]
}
Step 4: Create a Newnode
Newnode=getnode();
Step 5: Enter the element in the INFO field of Newnode
INFO[Newnode]=ITEM;
Step 6: Make a connection between the Newnode and the next node after
CURRPTR
LINK[Newnode]=LINK[Currptr]
Step 7: Make a link between Currptr and newnode
LINK[Currptr]=Newnode;
Step 8 : Exit
• Delete a node from the beginning:
• Algorithm:
Step 1 : check whether the list is empty
if ( start==NULL)
• write “ linked list is empty”
• else goto step 2
Step 2 : Set Currptr to start
Currptr=start;
Step 3 : Assign the link field of the first node to ‘start’ to delete the
original first node
start = link[start];
Step 4 : Free the deleted item
free(Currptr);
Step 5 : Exit
• Delete a node At the end:
• Algorithm:
Step 1 : check whether the list is empty
if ( start==NULL)
• write “ linked list is empty”
• else goto step 2
Step 2 : check if the list has only one element
if ( Link[start]==NULL) then
start=NULL;
else goto step 4
Step 3 : free the deleted node
free(start);
Step 4 : Assign start value to Currptr
Currptr=start;
Step 5 : Assign NULL to the another pointer PREVPTR
PREVPTR = NULL
Step 6 : Traverse the list until the Currptr points to last node
and PREVPTR points to the last before node
While(Link[Currptr]!=NULL)
{
PREVPTR=Currptr;
Currptr = Currptr -> link;
Step 7 : To make the LINK part of the last node, after
deletion to NULL
PREVPTR->LINK=NULL
Step 8 : Exit
• Delete a node at the given position:
• Algorithm:
 Step 1: Check for the position whether the deletion is at first position
if ( pos==1)
Algorithm for deleting a node at beginning
else goto Step 2
 Step 2 : Set Currptr to Start
Currptr=start
 Step 3: set PREVPTR to NULL
PREVPTR = NULL
Step 4 : if the item to be deleted is not at first position
for ( i=1; i<pos; i++ )
{
PREVPTR=Currptr;
Currptr = Currptr->link
}
•  Step 5 : LINK of PREVPTR is assigned with Link of
Currptr i.e. … make a link between the PREVPTR and the
next node of Currptr
PREVPTR  Link = Currptrlink
Step 6 : Exit
• Searching in a single linked list
• Algorithm :
• Step 1: set Currptr=start LOC = NULL
• Step 2: Repeat step 3 while (Currptr !=NULL)
• Step 3: if (item == Info [Currptr] )
– Then LOC = Currptr
– And display “ Search Successful “
– Exit
– else
– Currptr = Link [ Currptr ]
[ so Currptr, Now points to the next node ]
• Step 4: if LOC = NULL
Display “ Search unsuccessful “
• Step 5 : Exit
• Garbage Collection:
Garbage collection is the automatic reclamation of computer storage
The GC function is to find data objects that are no longer in use and make their
space available by the running program.
So Why Garbage Collection:
A software routine operating on data structure should not have to depend
what other routines may be operating on the same structure.
If the process does not free used memory the unused space is accumulated
until the process terminates.
Garbage collection is considered cheaper than explicit deal location
A good garbage collector shows a program down by factor of 10 percent.
Although it seems a lot , it is only a small price to pay for :
Convenience
Development time
Reliability

More Related Content

Similar to Presentation1.pptx

Data structures linked list introduction.pptx
Data structures linked list introduction.pptxData structures linked list introduction.pptx
Data structures linked list introduction.pptx
Kalpana Mohan
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
MeghaKulkarni27
 

Similar to Presentation1.pptx (20)

Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
 
Data Structure
Data StructureData Structure
Data Structure
 
Linked list
Linked listLinked list
Linked list
 
Singly link list
Singly link listSingly link list
Singly link list
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
Data structures linked list introduction.pptx
Data structures linked list introduction.pptxData structures linked list introduction.pptx
Data structures linked list introduction.pptx
 
Lect 11-12 Zaheer Abbas
Lect 11-12 Zaheer AbbasLect 11-12 Zaheer Abbas
Lect 11-12 Zaheer Abbas
 
Unit 2 linked list and queues
Unit 2   linked list and queuesUnit 2   linked list and queues
Unit 2 linked list and queues
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Stack - PPT Slides.pptx-data sturutures and algorithanms
Stack - PPT Slides.pptx-data sturutures and algorithanmsStack - PPT Slides.pptx-data sturutures and algorithanms
Stack - PPT Slides.pptx-data sturutures and algorithanms
 
Linked list
Linked listLinked list
Linked list
 
queue
queuequeue
queue
 
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
 
1. 3 singly linked list insertion 2
1. 3 singly linked list   insertion 21. 3 singly linked list   insertion 2
1. 3 singly linked list insertion 2
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
lecture-k-sorting.ppt
lecture-k-sorting.pptlecture-k-sorting.ppt
lecture-k-sorting.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
Lecture k-sorting
Lecture k-sortingLecture k-sorting
Lecture k-sorting
 
linkrd_list.pdf
linkrd_list.pdflinkrd_list.pdf
linkrd_list.pdf
 

More from Koteswari Kasireddy

Chapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfChapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdf
Koteswari Kasireddy
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
Koteswari Kasireddy
 
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Koteswari Kasireddy
 
Database System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptxDatabase System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptx
Koteswari Kasireddy
 

More from Koteswari Kasireddy (20)

DA Syllabus outline (2).pptx
DA Syllabus outline (2).pptxDA Syllabus outline (2).pptx
DA Syllabus outline (2).pptx
 
Chapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfChapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdf
 
Object_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdfObject_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdf
 
unit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdfunit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdf
 
DBMS_UNIT_1.pdf
DBMS_UNIT_1.pdfDBMS_UNIT_1.pdf
DBMS_UNIT_1.pdf
 
business analytics
business analyticsbusiness analytics
business analytics
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
 
CHAPTER -12 it.pptx
CHAPTER -12 it.pptxCHAPTER -12 it.pptx
CHAPTER -12 it.pptx
 
WEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptxWEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptx
 
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
 
Database System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptxDatabase System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptx
 
Evolution Of WEB_students.pptx
Evolution Of WEB_students.pptxEvolution Of WEB_students.pptx
Evolution Of WEB_students.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
 
Python_Functions_Unit1.pptx
Python_Functions_Unit1.pptxPython_Functions_Unit1.pptx
Python_Functions_Unit1.pptx
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 
linked_list.pptx
linked_list.pptxlinked_list.pptx
linked_list.pptx
 
matrices_and_loops.pptx
matrices_and_loops.pptxmatrices_and_loops.pptx
matrices_and_loops.pptx
 
algorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptxalgorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptx
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Presentation1.pptx

  • 1. Creating a Linked list : Algorithm : Create first node and assign the address of the first node to the pointer ‘start’. Step : 1 start =getnode( ); Use another pointer to store the address of the first node, called CURRPTR Step : 2 currptr=Start; Accept the item and store it in the INFO field of the node Step : 3 info[currptr ]= item; Accept the Choice from the keyboard whether to create another node or not Step : 4 if ( choice = ‘Y’) goto step 5 else goto step 6 If choice is ‘Y’ to create another node
  • 2. Step : 5 i) Newnode = getnode( ); Newnode which contains the address of the newly created node ii) link[currptr]=Newnode; Making a link between the original last node and present newnode iii) currptr=Newnode; Address of the Newnode is assigned to the original newnode iv) info[currptr]=item; Accepting the item and storing it in the info field of currptr go to step 4 If choice is ‘N’ to make the LINK field of the last node to NULL Step : 6 link [currptr] = NULL and Exit Step : 7 return
  • 3. • Traversing a linked list : Algorithm: Step 1 : Is linked list is empty if ( start ==NULL) display (“ linked list is empty “); exit( ) Step 2 : Assign start value to CURRPTR currptr=start; Step 3 : Repeat while(currptr!=NULL) Process info[currptr] Step 4 : currptr=link[currptr] /* moving the currptr from one node to the next node */ Step 5 : Exit
  • 4. • Algorithm for Displaying a list : • first check list is empty or not • Step 1 : if ( start == NULL) – Write (“ list is Empty”) – return; Store the Address of first node in another pointer CURRPTR • Step 2 : set currptr = start; • Step 3 : Repeat step4 and step5 while ( currptr !=NULL) • Display items one-by-one from first node until Currptr becomes NULL • Step 4 : display ( info[currptr]); After the display of this element ,Currptr should point to the next node • Step 5 : currptr=link[currptr]; • Step 6 : Exit
  • 5. • Insert operation at the beginning : • Algorithm : • Creating a node that is to be inserted • step 1 : Newnode =getnode( ); • Enter the item into the Info field of the New node • step 2 : info [Newnode]= item; • Assign the start value to the LINK part of the inserted node(New node). • It makes a link from ‘New node’ to the previous first node. • Now start and New node points to the original first node of the list. • It makes link between start and Newnode. • step 3 : link [Newnode]=start; • step 4 : start = Newnode; Exit;
  • 6. • Algorithm : insert operation at end Step 1 : if list is empty if ( start == NULL) insert at the beginning exit( ) end if Step 2 : currptr = start; Traverse the list to obtain the last node address Step 3 : while (link [currptr]! = NULL) currptr = link [ currptr] end while Create a newnode and enter the accepted ITEM into its INFO fields Step 4 : Newnode =getnode( ); Newnode -> info =item; Make a link between Currptr(last node) and New node Step 5 : link [currptr] = Newnode; Step 6 : link [Newnode] = NULL Step 7 : Exit
  • 7. • Algorithm for Inserting at certain position : Step 1: Set CURRPTR to Start Currptr=Start Step 2: If the item is to be inserted at 1st position if (pos==1) Algorithm for inserting at beginning Else go to step 3 Step 3: If the item to inserted at some position other than 1st position for ( i=0; i < pos-2;i++) { Currptr= LINK[Currptr] } Step 4: Create a Newnode Newnode=getnode();
  • 8. Step 5: Enter the element in the INFO field of Newnode INFO[Newnode]=ITEM; Step 6: Make a connection between the Newnode and the next node after CURRPTR LINK[Newnode]=LINK[Currptr] Step 7: Make a link between Currptr and newnode LINK[Currptr]=Newnode; Step 8 : Exit
  • 9. • Delete a node from the beginning: • Algorithm: Step 1 : check whether the list is empty if ( start==NULL) • write “ linked list is empty” • else goto step 2 Step 2 : Set Currptr to start Currptr=start; Step 3 : Assign the link field of the first node to ‘start’ to delete the original first node start = link[start]; Step 4 : Free the deleted item free(Currptr); Step 5 : Exit
  • 10. • Delete a node At the end: • Algorithm: Step 1 : check whether the list is empty if ( start==NULL) • write “ linked list is empty” • else goto step 2 Step 2 : check if the list has only one element if ( Link[start]==NULL) then start=NULL; else goto step 4 Step 3 : free the deleted node free(start); Step 4 : Assign start value to Currptr Currptr=start; Step 5 : Assign NULL to the another pointer PREVPTR PREVPTR = NULL
  • 11. Step 6 : Traverse the list until the Currptr points to last node and PREVPTR points to the last before node While(Link[Currptr]!=NULL) { PREVPTR=Currptr; Currptr = Currptr -> link; Step 7 : To make the LINK part of the last node, after deletion to NULL PREVPTR->LINK=NULL Step 8 : Exit
  • 12. • Delete a node at the given position: • Algorithm:  Step 1: Check for the position whether the deletion is at first position if ( pos==1) Algorithm for deleting a node at beginning else goto Step 2  Step 2 : Set Currptr to Start Currptr=start  Step 3: set PREVPTR to NULL PREVPTR = NULL Step 4 : if the item to be deleted is not at first position for ( i=1; i<pos; i++ ) { PREVPTR=Currptr; Currptr = Currptr->link }
  • 13. •  Step 5 : LINK of PREVPTR is assigned with Link of Currptr i.e. … make a link between the PREVPTR and the next node of Currptr PREVPTR  Link = Currptrlink Step 6 : Exit
  • 14. • Searching in a single linked list • Algorithm : • Step 1: set Currptr=start LOC = NULL • Step 2: Repeat step 3 while (Currptr !=NULL) • Step 3: if (item == Info [Currptr] ) – Then LOC = Currptr – And display “ Search Successful “ – Exit – else – Currptr = Link [ Currptr ] [ so Currptr, Now points to the next node ] • Step 4: if LOC = NULL Display “ Search unsuccessful “ • Step 5 : Exit
  • 15. • Garbage Collection: Garbage collection is the automatic reclamation of computer storage The GC function is to find data objects that are no longer in use and make their space available by the running program. So Why Garbage Collection: A software routine operating on data structure should not have to depend what other routines may be operating on the same structure. If the process does not free used memory the unused space is accumulated until the process terminates. Garbage collection is considered cheaper than explicit deal location A good garbage collector shows a program down by factor of 10 percent. Although it seems a lot , it is only a small price to pay for : Convenience Development time Reliability