Introduction to Linked Lists: Concepts, Applications, and Code Implementation, Lecture notes of Data Structures and Algorithms

An introduction to linked lists, a fundamental data structure in computer science. It covers the basic concepts, including nodes, data fields, and pointers, and explains various applications of linked lists in computer science and real-world scenarios. The document also includes code examples for inserting elements at the beginning and end of a linked list, as well as traversing the list. It concludes with an assignment to complete additional operations, such as inserting at a specific position, deleting nodes, searching for elements, and updating node values. This material is suitable for students learning data structures and algorithms.

Typology: Lecture notes

2022/2023

Available from 11/17/2025

marwan-ahmed-10
marwan-ahmed-10 🇪🇬

6 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Structures | Level 2 | Lab 5
1 | P a g e
Linked List (Part I)
1- What is the Liked List?
A linked list is a data structure that can store an indefinite amount of items. These items are
connected using pointers in a sequential manner.
Every element contains some data and a link to the next element.
The elements of a linked list are called the nodes. A node has two fields i.e. data and next.
The data field contains the data being stored in that specific node.
The next field contains the address of the next node.
2- Applications of linked list in computer science:
1. Implementation of stacks and queues.
2. Implementation of graphs: Adjacency list representation of graphs is most popular
which uses linked list to store adjacent vertices is.
3. Dynamic memory allocation: We use linked list of free blocks.
4. Performing arithmetic operations on long integers.
5. Manipulation of polynomials by storing constants in the node of linked list.
3- Applications of linked list in real world:
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.
pf3
pf4

Partial preview of the text

Download Introduction to Linked Lists: Concepts, Applications, and Code Implementation and more Lecture notes Data Structures and Algorithms in PDF only on Docsity!

Linked List (Part I)

1- What is the Liked List?

A linked list is a data structure that can store an indefinite amount of items. These items are

connected using pointers in a sequential manner.

 Every element contains some data and a link to the next element.

 The elements of a linked list are called the nodes. A node has two fields i.e. data and next.

 The data field contains the data being stored in that specific node.

 The next field contains the address of the next node.

2 - Applications of linked list in computer science :

1. Implementation of stacks and queues.

2. Implementation of graphs: Adjacency list representation of graphs is most popular

which uses linked list to store adjacent vertices is.

3. Dynamic memory allocation: We use linked list of free blocks.

4. Performing arithmetic operations on long integers.

5. Manipulation of polynomials by storing constants in the node of linked list.

3 - Applications of linked list in real world:

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.

4 - Linked List Operations:

1) Insert element in the Beginning.

2) Insert element to the End (Append).

3) Insert element in Particular Position.

4) Traverse (Display) Linked List.

5) Delete element from the Beginning.

6) Delete element from the End.

7) Delete Element from Particular Position.

8) Find Element (Search).

Linked List Code ( Part I):

#include using namespace std; void main (); struct node { int data; node *next; }; node * head = NULL; void InsertB(int item)//Insert to Beginning { node * temp = new node; //(1)Create new node temp->data = item; //(2)Fill the Data temp->next = head; //(3)Link to old list head = temp; //(4)Move start pointer to new node main(); } void InsertE(int item) //Insert to End (Append) { node * temp = new node; temp->data = item; temp->next=NULL; if(head == NULL) //List is Empty { head = temp; } else // List is not Empty { node *end=head; while (end->next !=NULL) { end=end->next; }

case'z':case'Z':exit(0); } delete head; }

Output:

Assignment:

 Complete the following Operations to Linked List Program:

1. Insert node at position.

Bonus:

2. Delete first Node.

3. Delete last Node.

4. Search for Element.

5. Update Node Value.

By using Function for each operation.