Thursday, August 7, 2025

DSA using Python: Assignment 3 – Singly Linked List (SLL)



About Singly Linked List

In this assignment, we implement a Singly Linked List (SLL) using Python. We build the structure using classes, define insertion and deletion operations, and also add methods for searching and iterating over the list. This is a fundamental concept in Data Structures and Algorithms (DSA).


Assignment 3 – Singly Linked List (SLL)

### ✅ Task 1: Define Node Class
Define a class `Node` to describe a node of a singly linked list.

### ✅ Task 2: Define SLL Class
Implement `__init__()` method to create and initialise the `start` reference variable.

### ✅ Task 3: is_empty()
Method to check if the list is empty.

### ✅ Task 4: insert_at_start()
Insert element at the **start** of the list.

### ✅ Task 5: insert_at_last()
Insert element at the **end** of the list.

### ✅ Task 6: search()
Search for a node with a given value.

### ✅ Task 7: insert_after()
Insert new node after a given node.

### ✅ Task 8: print_all()
Print all elements of the list.

### ✅ Task 9: Iterator
Implement an iterator to access all elements in a sequence.

### ✅ Task 10: delete_first()
Delete the **first** node.

### ✅ Task 11: delete_last()
Delete the **last** node.

### ✅ Task 12: delete_item()
Delete a node with specific value.


This assignment helped in building the core structure of singly linked lists in Python. Understanding how to create nodes and link them using a class-based approach is essential for real-world linked list problems in coding interviews and DSA practice.


No comments:

Post a Comment

DSA using Python: Assignment 3 – Singly Linked List (SLL)

Follow Me About Singly Linked List In this assignment, we implement a Singly Linked List (SLL) using Python. We build the structure using cl...