DS - Lecture 04 - 20180820

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

IT 4043

Data Structures and


Algorithms
Lecture 04
Dr. Pradeep Kalansooriya
Senior Lecturer
Head – Department of IT
Faculty of Computing
Linked Lists
Linked List
Structure

• Linked List
{
link head;
link tail;
};
Singly Linked List
Create an empty list
Linked List
Operations
• Create an empty list
• Insert node into head
• Insert node into tail
• Insert node into specific location
• Delete node
• Check IsEmpty
• Print List
Singly Linked List
Create an empty list
Example
Create three node linked list

Head Tail

10 8 50
Example
Create three node linked list
IntNode p = new IntNode(10);

10

p.next;
10
Example
Create three node linked list
p.Next = new IntNode(8);

p.next.next;
10 8
Example
Create three node linked list
p.Next = new IntNode(50);

50

10 8 50 p.next.next;
Example
Create three node linked list

Head Tail
Head
10 8 50
Tail

You might also like