SlideShare a Scribd company logo
1 of 9
Operations on Single Linked Lists

 Objectives
 In this lesson, you will learn to:
  Implement the following operations on single linked
   list:
      Traversing a linked list
      Querying information
      Deleting nodes
      Sorting lists




   ©NIIT                   Operations On Single Linked List/Lesson 2/Slide 1 of 9
Operations on 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




   ©NIIT                 Operations On Single Linked List/Lesson 2/Slide 2 of 9
Operations on Single Linked Lists


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




   ©NIIT               Operations On Single Linked List/Lesson 2/Slide 3 of 9
Operations on 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 which matches 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




   ©NIIT                 Operations On Single Linked List/Lesson 2/Slide 4 of 9
Operations on Single Linked Lists


   Deleting Nodes
    Can be done in two forms:
       Logical 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)




   ©NIIT                 Operations On Single Linked List/Lesson 2/Slide 5 of 9
Operations on 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

   ©NIIT                 Operations On Single Linked List/Lesson 2/Slide 6 of 9
Operations on Single Linked Lists


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




   ©NIIT                 Operations On Single Linked List/Lesson 2/Slide 7 of 9
Operations on Single Linked Lists


   Problem Statement 2.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, the user can view customer details.




   ©NIIT               Operations On Single Linked List/Lesson 2/Slide 8 of 9
Operations on Single Linked Lists

 Summary
  To display the contents of the list, you need to
   traverse the list.
  Linked list can be queried, to display the data stored
   in a list.
  The deletion of a node can be performed at three
   different levels:
      At the beginning of the list
      In the middle of the list
      At the end of the list



   ©NIIT                  Operations On Single Linked List/Lesson 2/Slide 9 of 9

More Related Content

What's hot

DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESsuthi
 
Smu mscit sem 2 fall 2015 solved assignments
Smu mscit sem 2 fall 2015 solved assignmentsSmu mscit sem 2 fall 2015 solved assignments
Smu mscit sem 2 fall 2015 solved assignmentssmumbahelp
 
DBMS Question bank
DBMS Question bankDBMS Question bank
DBMS Question bankSara Sahu
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesFellowBuddy.com
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data StructureJazz Jinia Bhowmik
 
LATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATION
LATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATIONLATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATION
LATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATIONcsandit
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersAbdul Rahman Sherzad
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)ShrushtiGole
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
DBMS Assignments Questions
DBMS Assignments QuestionsDBMS Assignments Questions
DBMS Assignments QuestionsSara Sahu
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 

What's hot (20)

DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTES
 
Smu mscit sem 2 fall 2015 solved assignments
Smu mscit sem 2 fall 2015 solved assignmentsSmu mscit sem 2 fall 2015 solved assignments
Smu mscit sem 2 fall 2015 solved assignments
 
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
 
DBMS Question bank
DBMS Question bankDBMS Question bank
DBMS Question bank
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
 
Semi join
Semi joinSemi join
Semi join
 
Lesson 1 overview
Lesson 1   overviewLesson 1   overview
Lesson 1 overview
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
Types of datastructures
Types of datastructuresTypes of datastructures
Types of datastructures
 
LATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATION
LATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATIONLATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATION
LATTICE-CELL : HYBRID APPROACH FOR TEXT CATEGORIZATION
 
XL-MINER: Data Exploration
XL-MINER: Data ExplorationXL-MINER: Data Exploration
XL-MINER: Data Exploration
 
Data structures
Data structuresData structures
Data structures
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)
 
Data structures
Data structuresData structures
Data structures
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
XL-MINER: Associations
XL-MINER: AssociationsXL-MINER: Associations
XL-MINER: Associations
 
DBMS Assignments Questions
DBMS Assignments QuestionsDBMS Assignments Questions
DBMS Assignments Questions
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 

Similar to Operations on Single Linked Lists Guide

Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked ListThenmozhiK5
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure shameen khan
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfKamranAli649587
 
data structures lists operation of lists
data structures lists operation of listsdata structures lists operation of lists
data structures lists operation of listsmuskans14
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testspriyanshukumar97908
 
Algorithms
AlgorithmsAlgorithms
AlgorithmsDevMix
 
IBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash JoinIBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash JoinAjay Gupte
 
Lecture4a dynamic data_structure
Lecture4a dynamic data_structureLecture4a dynamic data_structure
Lecture4a dynamic data_structurembadhi barnabas
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using pythonLavanyaJ28
 
Deletion from single way linked list and search
Deletion from single way linked list and searchDeletion from single way linked list and search
Deletion from single way linked list and searchEstiak Khan
 
ECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docxECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docxSALU18
 

Similar to Operations on Single Linked Lists Guide (20)

Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked List
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 
02. the linked lists (1)
02. the linked lists (1)02. the linked lists (1)
02. the linked lists (1)
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Universe
UniverseUniverse
Universe
 
Linked list (1).pptx
Linked list (1).pptxLinked list (1).pptx
Linked list (1).pptx
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
 
data structures lists operation of lists
data structures lists operation of listsdata structures lists operation of lists
data structures lists operation of lists
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and tests
 
DATASTORAGE.pdf
DATASTORAGE.pdfDATASTORAGE.pdf
DATASTORAGE.pdf
 
DATASTORAGE
DATASTORAGEDATASTORAGE
DATASTORAGE
 
Link list
Link listLink list
Link list
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
IBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash JoinIBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash Join
 
Lecture4a dynamic data_structure
Lecture4a dynamic data_structureLecture4a dynamic data_structure
Lecture4a dynamic data_structure
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
 
DATASTORAGE.pptx
DATASTORAGE.pptxDATASTORAGE.pptx
DATASTORAGE.pptx
 
Deletion from single way linked list and search
Deletion from single way linked list and searchDeletion from single way linked list and search
Deletion from single way linked list and search
 
ECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docxECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docx
 
Faq dbms
Faq dbmsFaq dbms
Faq dbms
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Operations on Single Linked Lists Guide

  • 1. Operations on Single Linked Lists Objectives In this lesson, you will learn to: Implement the following operations on single linked list: Traversing a linked list Querying information Deleting nodes Sorting lists ©NIIT Operations On Single Linked List/Lesson 2/Slide 1 of 9
  • 2. Operations on 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 ©NIIT Operations On Single Linked List/Lesson 2/Slide 2 of 9
  • 3. Operations on Single Linked Lists Problem Statement 2.D.1 Create an application that accepts the names of an unknown number of customers and displays them in alphabetical order. ©NIIT Operations On Single Linked List/Lesson 2/Slide 3 of 9
  • 4. Operations on 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 which matches 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 ©NIIT Operations On Single Linked List/Lesson 2/Slide 4 of 9
  • 5. Operations on Single Linked Lists Deleting Nodes Can be done in two forms: Logical 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) ©NIIT Operations On Single Linked List/Lesson 2/Slide 5 of 9
  • 6. Operations on 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 ©NIIT Operations On Single Linked List/Lesson 2/Slide 6 of 9
  • 7. Operations on Single Linked Lists Problem Statement 2.D.2 Modify the above application to allow deletion of unwanted customer records. ©NIIT Operations On Single Linked List/Lesson 2/Slide 7 of 9
  • 8. Operations on Single Linked Lists Problem Statement 2.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, the user can view customer details. ©NIIT Operations On Single Linked List/Lesson 2/Slide 8 of 9
  • 9. Operations on Single Linked Lists Summary To display the contents of the list, you need to traverse the list. Linked list can be queried, to display the data stored in a list. The deletion of a node can be performed at three different levels: At the beginning of the list In the middle of the list At the end of the list ©NIIT Operations On Single Linked List/Lesson 2/Slide 9 of 9