CSS 433 GROUP 3 Edited
CSS 433 GROUP 3 Edited
Bamiboje Mofijifolouwa
A linked list is a linear collection of data elements whose order is not given
by their physical placement in memory. Instead, each element points to the
next.
The addition of additional links in more complex variants enables the more
effective insertion or removal of nodes at any location. The linear access
time of linked lists is a disadvantage (and difficult to pipeline).
Faster access, such as random access, is not feasible. Arrays have better
cache locality compared to linked lists.
TYPES OF LISTS
There are three common types of Linked Lists. And they include;
For the sake of this study, we will center focus on just the Circular and
Doubly linked list
A circularly linked list is a type of linked list where the first node and the last
node are connected to form a circle. It can also be referred to as a
sequence of nodes such that each node can be retraced to itself with no
NULL at the end. A "node" in this context is a self-referential element with
pointers to one or two other nodes nearby.
Basic Circular Linked List Operations
Below are the basic operations that can be performed on a circular linked
list:
1. Insertion : Inserts a node at the start of the list
2. Deletion: Deletes a node at the start of the list
3. Display: Displays the list
Create a node, T.
Make T -> next = last -> next: here we update the next part of the
new node so that it can point to the last node
last -> next = T: and lastly we update the next part of the last node so
that it can point to T
Circular linked list before insertion
And then,
Insertion at the end of the list: To insert a node at the end of the list, follow
these steps:
Create a node, say T.
Make T -> next = last -> next;
last -> next = T.
last = T.
Before insertion,
After insertion,
1. Circular Singly Linked List: In a circular singly linked list, the address
of the last node consists of the address of the first node. We traverse a
circular singly linked list until we reach the same node that we started from.
The circular singly linked list has no beginning or end and no null value is
present in the next part of any of the nodes.
2. Circular Doubly Linked List: for a circular doubly linked list, in addition
to the last node storing the address of the first node, the first node will also
store the address of the last node. Circular Doubly Linked List has
properties of both doubly linked list and circular linked list in which two
consecutive elements are linked or connected by the previous and next
pointer and the last node points to the first node by the next pointer and
also the first node points to the last node by the previous pointer.
Advantages of Circular Linked Lists
1. From the last node, or the head node, one can travel back to the first.
2. The starting node is irrelevant because we can traverse all nodes
regardless of which node we choose to start at.
3. The previous node is clearly visible.
4. A NULL function is not required in the code. Unless it is fully
assigned, a NULL identifier is never identified by the circular list.
5. Online queues can be successfully finished by algorithms like Round
Robin setup without having to deal with NULL suspension or
reference references.
1. The circular nature of the circular linked list can result in an infinite
loop if it is not handled properly.
2. We must traverse the entire list after inserting at the start in order to
locate the final node.
3. It is not possible to access elements directly.
4. Reversing a circular linked list is generally a challenging task.
Each node in a "doubly linked list" has a second link field that points to the
node that comes before it in the sequence in addition to the next-node link.
The two links could be referred to as "forward" and "backwards" or "next"
and "prev" (or "previous"). A doubly linked list is bidirectional and can be
traversed in both directions
Every SLL is composed of a head and a tail. A pointer to the first element is
located at the head of each SLL, and a pointer to the last element is
located at the tail.
Basic Operations
The basic operations supported by a list are as follows.