Documentation On Linked List in Data Structures and Algorithms 3
Documentation On Linked List in Data Structures and Algorithms 3
LEADER:
ALLEXIA, PAPA D. – PREZI, DOCUMENTATION, CODING
MEMBERS:
FABUL, APRIL JOY G. – LIFE SCENARIO
PAGALAN, MIKECAELLA M. – DOCUMENTATION, OBJECTIVES, CODING
PELAEZ, JHON CEDRICK C. – CONCLUSION, LIFE SCENARIO
PERLAS, CHARLS B. – EXAMPLE, CODING
DE PADUA, JERIC – INTRODUCTION, CODING
INTRODUCTION TO LINKED LIST
Linked list is one of the most important data structures to maintain information.
A node holds two elements, namely, data and a reference, or pointer to the next node in the sequence to
form a chain of linked nodes.
In this documentation, we will discuss the structure, operations, and types of linked lists.
Beginning with the basic components of a linked list, including nodes, data, and pointers, we discuss
important operations found in a linked list: insertion, deletion, traversal, and searching.
We will then proceed to discuss the various types of linked lists, like singly linked lists, doubly linked
lists, and circular linked lists.
For better understanding, we'll use examples taken from real-life scenarios of using linked lists:
queue at a ticket booth, video editing, Ferris wheel.
Finally, we will write each of the above-mentioned types of linked list in JavaScript, providing
examples for every one of them. By the end of this document, you will have a good knowledge of how linked
lists are one of the powerful things used in programming.
OBJECTIVES
By the end of this documentation, you will:
Understand the Structure of Linked Lists: Learn the building blocks of linked lists, including
nodes, data, and pointers.
Learn Linked List Operations: Master key operations such as insertion, deletion, traversal, and
searching for singly, doubly, and circular linked lists.
Explore Types of Linked Lists: Understand the three main types: singly, doubly, and circular linked
lists, and learn their unique properties and implementations.
Understand Practical Applications: Identify the real-life uses of linked lists in task scheduling, web
browsers, music playlist, and other scenarios.
Implement Linked Lists in JavaScript: Create and manipulate linked lists with JavaScript code
implementations for each type.
WHAT IS A LINKED LIST?
A linked list is an arrangement of nodes, and each of the nodes holds two parts:
Data: the value actually stored in the node.
Next Pointer: refers to a reference that points at the next node in the sequence.
A linked list begins with a head pointer that refers to the first node within the list. If the list is empty,
the head refers to the null.
1. Insertion
At the Beginning: Add a node to the front of the list.
At the End: Add a node to the end of the list.
After a Given Node: Add a node after a specific node in the list.
2. Deletion
From the Beginning: Removing the first node.
From the End: Removing the last node.
A Specific Node: Removing a node with a specified value.
3. Traversal in Singly Linked List
4. Searching
Find a node with a given value from the list; this, generally, requires all the traversal from the beginning of
a list until it finds a desired value.
TYPES OF LINKED LISTS
1. Singly Linked List
In a Singly Linked List, each node contains both data and a reference to the next node. Traversal is one
way; from one node to another until the last node whose next pointer is null.
A doubly linked list has two pointers in every node: one pointing to the next node and another to the
previous node. It is, therefore, more versatile than a singly linked list because it can be traversed in either
direction.
Operations:
1. Insert at the beginning (enqueue): A new person joins the queue at the front.
2. Insert at the back (enqueue): A new person joins the queue at the back.
3. Insert at a given position: A person joins the queue at a given position (e.g., someone cutting in line).
Example scenarios:
New customer comes to the ticket counter:
o Add the person to the tail of the linked list (insert at the back).