Unit 2
Unit 2
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.
CONTENT
Single linked lists
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.
Traversing Link List is visiting each node of the list once in order to
perform some operation on it.
Traverse a Linked 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
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