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

BCA Data Structure Unit 1 Notes

The document provides an overview of linked lists, detailing their structure, including nodes that contain data and pointers to the next node. It explains different types of linked lists such as singly linked lists, doubly linked lists, header linked lists, and circular linked lists, highlighting their unique features and representations. The document emphasizes the importance of pointers in connecting nodes and the role of the head and tail in a linked list.

Uploaded by

katrepankajd
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

BCA Data Structure Unit 1 Notes

The document provides an overview of linked lists, detailing their structure, including nodes that contain data and pointers to the next node. It explains different types of linked lists such as singly linked lists, doubly linked lists, header linked lists, and circular linked lists, highlighting their unique features and representations. The document emphasizes the importance of pointers in connecting nodes and the role of the head and tail in a linked list.

Uploaded by

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

Unit 1

Linked List
A linked list is a sequence of nodes that contain two fields: data (an integer value here as an
example) and a link to the next node. The last node is linked to a terminator used to signify
the end of the list.

Each record of a linked list is often called an 'element' or 'node'.

The field of each node that contains the address of the next node is usually called the 'next
link' or 'next pointer'. The remaining fields are known as the 'data', 'information', 'value',
'cargo', or 'payload' fields.

The 'head' of a list is its first node. The 'tail' of a list may refer either to the rest of the list after
the head, or to the last node in the list.

Representation of Singly Linked List

Let's consider four elements to insert into the list.


We have four nodes, each consisting of a data part and address part stored at some address. In
the singly linked list, we have a special node called the head node that holds the address of
the first node, and the last node points to Null.
Every node in a linked list connects with the other through a pointer that points to the address
of the next node, and arrows in the above-given diagram represent that.
In a linked list, each node connects through a pointer that points to the address of its next
node, and arrows in the above-given diagram represent that.
For Example:

Let our elements to insert be 10, 20, 30, and 40.


 The head node holds the address of the first node.
 The next part of the first node holds the address of the next node, address 2.
 Similarly, the second node holds the address of the third node, address 3.
 The third node holds the address of its next node, address 4. which follows till the last
node that is pointing to the Null. In this way, they link together.
Representation of Double linked list in memory

A doubly linked list is represented as follows:

The above list is comprised of 4 nodes having four data points- A, B, C, D. Each node has
two links one pointing forward and one pointing backwards.

Each node has the following structure:

It comprises of two pointers and a data field.

a. Data: It constitutes the value of the data item inside the list.
b. Prev: It is a pointer pointing towards the previous node. For the first node, Prev points to
NULL.
c. Next: It links the current node to the next node in the linked list. The ‘Next’ of the last
node points towards NULL.

Representation of Header Linked List


A header linked list is a type of linked list that has a header node at the beginning of the list.
In a header linked list, HEAD points to the header node instead of the first node of the list.

The header node does not represent an item in the linked list. This data part of this node is
generally used to hold any global information about the entire linked list. The next part of the
header node points to the first node in the list.

A header linked is a special kind of linked list which contains a special node at the beginning
of the list. This special node is known as header node and contain important information
regarding the linked list. This information may be total number of nodes in list, some
description for the user like creation and modification data about, whether the data in the list
is sorted and unsorted.

Representation of Circular single Linked List

You might also like