0% found this document useful (0 votes)
5 views

Singly Linked List

Uploaded by

hoang_humg
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Singly Linked List

Uploaded by

hoang_humg
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Data Structure : Introduction to Linked List

CategoriesData Structures2 mins readJanuary 12, 2023

Linked list is a ADT(Abstract Data Type) consisting of group of nodes in a


connected way forming a sequence. A linked list is used to maintain dynamic
series of data. Each node of a linked list basically contains only two parts data
part and the address part. Data part of the node hold the actual data while
the address part of the node holds the reference or address to its next
connected node. Linked list got its name because here each list (node) is
linked to another list (node).

Here in the picture you can see that a linked list is composed mainly of nodes
and each node contains the address of its next connected node.

What is a Node?
A node is the main structure of the linked list. It contains all details about the
data and the address of next node. A node can contain many data fields and
many address fields, but should contain at least one address field. Address
part of last node contains a NULL value specifying end of the list. In computer
programming a node can be represented either by structures (struct in C or
C++) or by classes (class in C++ or Java) and address part of a node is
basically represented by pointers (in C and C++). Here is a basic structure of
a node in C programming language.
/*Basic structure of a node*/
struct node {
int data; // Data
struct node * next; // Address
};
Copy

Advantages of linked list


 Linked list provides dynamic allocation of memory, which
allocates memory as per need during the execution of a program.
 It is one of the simplest data structure to implement.
 Insertion and deletion of data from the list is easy.

Disadvantages of linked list


 In order to access any element of a linked list the user has to
access it in a sequential manner form the start of the list.
 Linked list generally occupy more memory than arrays due to
extra storage space for address fields.
 Since elements of a linked list are not stored in a contiguous way
hence accessing time of each element is slightly greater.

Data Structure : Singly Linked list


CategoriesData Structures2 mins readJanuary 12, 2023

Singly linked list is a basic linked list type. Singly linked list is a collection of
nodes linked together in a sequential way where each node of singly linked list
contains a data field and an address field which contains the reference of the
next node. Singly linked list can contain multiple data fields but should contain
at least single address field pointing to its connected next node.
To perform any operation on a linked list we must keep track/reference of the
first node which may be referred by head pointer variable. In singly linked list
address field of last node must contain a NULL value specifying end of the list.

Basic structure of a singly linked list


Each node of a singly linked list follows a common basic structure. In a node
we can store more than one data fields but we need at least single address
field to store the address of next connected node.

struct node {
int data; // Data
struct node * next; // Address
};
Copy

Advantages of Singly linked list


There are several points about singly linked list that makes it an important
data structure.

 Singly linked list is probably the most easiest data structure to


implement.
 Insertion and deletion of element can be done easily.
 Insertion and deletion of elements doesn’t requires movement of
all elements when compared to an array.
 Requires less memory when compared to doubly, circular or
doubly circular linked list.
 Can allocate or deallocate memory easily when required during its
execution.
 It is one of most efficient data structure to implement when
traversing in one direction is required.

Disadvantages of Singly linked list


After seeing the advantages of singly linked list. Singly linked list also has
some disadvantages over other data structures.

 It uses more memory when compared to an array.


 Since elements are not stored sequentially hence requires more
time to access each elements of list.
 Traversing in reverse is not possible in case of Singly linked list
when compared to Doubly linked list.
 Requires O(n) time on appending a new node to end. Which is
relatively very high when compared to array or other linked list.

You might also like