Singly Linked List in Python: Objective
Singly Linked List in Python: Objective
Objective
– Understand the concepts of singly linked lists
– Implement singly linked list using dynamic structures
Linked Lists:
A linked list is a data structure consisting of a group of nodes which together represent a
sequence. Under the simplest form, each node is composed of a datum and a reference (in
other words, a link) to the next node in the sequence; more complex variants add additional
links. This structure allows for efficient insertion or removal of elements from any position in the
sequence.
last
first
Representation:
A linked list is represented by a pointer to the first node of the linked list. The first node is called
the head. If the linked list is empty, then the value of the head is NULL.
1) data
# Node class
class Node:
LAB TASK
Consider a scenario where a University wants to maintain the data of books in library. The data
containing Book ID, Book Name, Author Name are saved in a singly linked list.
Book ID Next
BName
AName