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

Data Structures and Algorithm

Data structures are methods for organizing and storing data so it can be accessed efficiently. A linked list is a linear data structure where each element consists of the data and a pointer to the next node. There are different types of linked lists including singly linked, doubly linked, and circular linked lists. Linked lists allow dynamic size and efficient insertion/deletion of nodes anywhere in the list compared to arrays. Common linked list operations include traversing the list, inserting nodes, deleting nodes, searching, and sorting.

Uploaded by

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

Data Structures and Algorithm

Data structures are methods for organizing and storing data so it can be accessed efficiently. A linked list is a linear data structure where each element consists of the data and a pointer to the next node. There are different types of linked lists including singly linked, doubly linked, and circular linked lists. Linked lists allow dynamic size and efficient insertion/deletion of nodes anywhere in the list compared to arrays. Common linked list operations include traversing the list, inserting nodes, deleting nodes, searching, and sorting.

Uploaded by

Omkar Jha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Introduction

What is Data Structure?


Data structure is a storage method that is used to store and organize
data. It is a way of arranging data on a computer so that it can be
accessed and updated efficiently.

Types of Data Structure

• Linear Data Structure


• Non-linear Data Structure

Linear data structures

In linear data structures, the elements are arranged in sequence one


after the other. Since elements are arranged in particular order, they
are easy to implement.

Different types of Linear Data Structures are : Array, Stack, Linked


List, Stack, Queue.

Linked List Data Structure


In linked list data structure, data elements are connected through a
series of nodes. And, each node contains the data items and address
to the next node. Each link contains a connection to another link.

1
Representation of a Linked List

Types of Linked List


1. Singly Linked List :

A singly linked list is a type of linked list that is unidirectional, that is,
it can be traversed in only one direction from head to the last node
(tail). Each element in a linked list is called a node.

2. Doubly Linked List :

Doubly linked list is a complex type of linked list in which a node


contains a pointer to the previous as well as the next node in the
sequence. Therefore, in a doubly linked list, a node consists of three
parts: node data, pointer to the next node in sequence (next pointer) ,
pointer to the previous node (previous pointer).

2
3. Circular Linked List :

A circular linked list is a type of linked list in which the first and the
last nodes are also connected to each other to form a circle. Here, the
address of the last node consists of the address of the first node.

Motivation
Why do we need Linked Lists?
1. Image viewer – Previous and next images are linked, hence can be
accessed by next and previous button.
2. Previous and next page in web browser – We can access previous
and next url searched in web browser by pressing back and next button
since, they are linked as linked list.
3. Music Player – Songs in music player are linked to previous and next
song. you can play songs either from starting or ending of the list.

Advantage of Linked List over Array


1. Items can be added or removed from the middle of the list
2. There is no need to define an initial size
3. Dynamic : a linked list can easily grow and shrink in size

3
Methodology
In a linked list, operations such as traversal, insertion, deletion,
search and sort can be performed. Some of the operations are
mentioned below.
Operations Of a Linked List :
• IsEmpty( ) :
➢ Determine whether or not the list is empty
• InsertNode :
➢ Insert a new node at a particular position
• DeleteNode :
➢ Delete a node with a given value.
• DisplayList :
➢ Print all the nodes in the list
• FindNode :
➢ Returns the position of the node.
Illustration

Output:

4
In the above program, created a singly linked list and display all the
nodes present in the list.

Algorithm

1. Create a class Node which has two attributes: data and next.
Next is a pointer to the next node.
2. Create another class which has two attributes: head and tail.
3. addNode() will add a new node to the list:
1. Create a new node.
2. It first checks, whether the head is equal to null which
means the list is empty.
3. If the list is empty, both head and tail will point to the
newly added node.
4. If the list is not empty, the new node will be added to end
of the list such that tail's next will point to the newly added
node. This new node will become the new tail of the list.
4. display() will display the nodes present in the list:
1. Define a node current which initially points to the head of the
list.
2. Traverse through the list till current points to null.
3. Display each node by making current to point to node next
to it in each iteration.

5
Illustration

Output

In the above program, we created a singly linked list and delete an element
and then the sorted list is displayed present in the list.

Conclusion
In this report, I got to know about “Linked List in data structure” of “Data
Structure and Algorithms”. I got to know that a Linked List is a linear data
structure that are connected through a series of nodes. And, each node
contains the data items and address to the next node. Most importantly, we
could understand that with the help of real-life problems. We are also aware
of the advantages and applications of using Linked List in data structure.
There are various operations of an Linked List which can be performed in C.
This was an informative project and would help me in future.

6
7

You might also like