0% found this document useful (0 votes)
24 views30 pages

Unit 2

Uploaded by

aghiadhamchado
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views30 pages

Unit 2

Uploaded by

aghiadhamchado
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

DATA STRUCTURE

By,
Dr. Mamata P. Wagh
Deptt. of CSE
C. V. Raman Global University
Bhubaneswar
COURSE OUTCOMES:

CO1:
 Understand of linear data structure such as Queue and Stack for solving Problems.

CO2: Analyse linear data structure such as Linked List for solving problems.

CO3: Apply non-linear data structure such as Tree for solving problems.

CO4: Apply non-linear data structure such as Graph for solving problems.

CO5: Create a program using different sorting and searching mechanisms.


Unit-II

CONTENT
 Single linked lists

 Operations and iplementation

 Double linked list

 Operations and iplementation

 Circular list: concepts and


implementation

 Applications of linked lists


SINGLY LINK LIST:

 Linked List can be defined as collection of objects called nodes that are
randomly stored in the memory.

 A node contains two fields i.e., data stored at that particular address and the
pointer which contains the address of the next node in the memory.

 The last node of the list contains pointer to the null.


nODE rEPRESENTATION
OPERATIONS ON SINGLY LINK LIST

 Traversal - access each element of the linked list

 Insertion - adds a new element to the linked list

 Deletion - removes the existing elements

 Search - find a node in the linked list

 Sort - sort the nodes of the linked list


Traverse a Linked List

 Traversing Link List is visiting each node of the list once in order to
perform some operation on it.
Traverse a Linked List

The algorithm for traversing a list

(i) Start with the head of the list. Access the content of the head node if it is

not null.
(ii) Then go to the next node(if exists) and access the node information
(iii) Continue until no more nodes (that is, you have reached the null node)
Traverse a Linked List

Operations ON SINGLY LINK LIST: SEARCHING
Ex: Element to be searched = 4
Operations ON SINGLY LINK LIST:
 Algorithm for Search Operation
OPERATIONS ON SINGLY LINK LIST

 Insertion - adds a new element to the linked list

There are four cases for inserting a node in link list

 Case 1: The new node is inserted at the beginning.


 Case 2: The new node is inserted at the end.
 Case 3: The new node is inserted after a given node.
 Case 4: The new node is inserted before a given node.
OPERATIONS ON SINGLY LINK LIST
Case 1: Inserting a Node at the Beginning of a Linked List.
Suppose we want to add a new node with data 9.
OPERATIONS ON SINGLY LINK LIST
Case 1: Inserting a Node at the Beginning of a Linked List.
Case 2: Inserting a Node at the End of a Linked List
OPERATIONS ON SINGLY LINK LIST
Case 2: Inserting a Node at the End of a Linked List
Case 3: Inserting a Node After a Given Node in a Linked List

Suppose we want to add a new node with value 9 after the node containing 3 .
Case 3: Inserting a Node After a Given Node in a Linked List
OPERATIONS ON SINGLY LINK LIST
Case 3: Inserting a Node After a Given Node in a Linked List
Case 4: Inserting a Node Before a Given Node in a Linked List

Suppose we want to add a new node with value 9 before the node containing 3 .
Case 4: Inserting a Node Before a Given Node in a Linked List

Suppose we want to add a new node with value 9 before the node containing 3 .
Case 4: Inserting a Node Before a Given Node in a Linked List ...... continue
OPERATIONS ON SINGLY LINK LIST
Case 4: Inserting a Node Before a Given Node in a Linked List
OPERATIONS ON SINGLY LINK LIST

Deleting a Node from a Linked List:


How to delete a node from an already existing linked list.
There are three cases:
Case 1: The first node is deleted.
Case 2: The last node is deleted.
Case 3: The node after a given node is deleted.
OPERATIONS ON SINGLY LINK LIST

Deleting a Node from a Linked List:


How to delete a node from an already existing linked list.
There are three cases:
Case 1: The first node is deleted.
Case 2: The last node is deleted.
Case 3: The node after a given node is deleted.
OPERATIONS ON SINGLY LINK LIST
Case 1: Deleting a First Node from a Linked List
OPERATIONS ON SINGLY LINK LIST
Case 2: Deleting the Last Node from a Linked List
OPERATIONS ON SINGLY LINK LIST
Case 2: Deleting the Last Node from a Linked List
Case 3: Deleting After a Given Node in a Linked List
Suppose we want to delete the node that succeeds the node which contains data value 4 .
OPERATIONS ON SINGLY LINK LIST
Case 3: Deleting After a Given Node in a Linked List

You might also like