Friday, July 12, 2024

Singly Linked List Code (Question)

Follow me

Singly Linked List Code Questions


Note: First Make a Diagram / Algorithm on your copy or notebook  =>  Label your diagram as per your requirement  =>  Write a  code on computer  =>  Verify your code  =>  Run your code.


Singly Linked List


1. Define a class Node to describe a node of a singly linked list.

2. Define a class SLL to implement Singly Linked List with __init__() method to create and initialize start reference variable.

3. Define a method is_empty() to check if the linked list is empty in SLL class.

4. In class SLL, define a method insert_at_start() to insert an element at the starting of the list.

Insert Before Head


Insert Before a given Node


5. In class SLL, define a method insert_at_last() to insert an element at the end of the list.

6. In class SLL, define a method search() to find the node with specified element value.



Searching of Node


7. In class SLL, define a method insert_between_nodes() to insert a new node after a given node of the list.

8. In class SLL, define a method to print all the elements of the list.

9. In class SLL, define a method delete_first() to delete first element from the list.

Deletion of Node

10. In class SLL, define a method delete_last() to delete last element from the list.

11. In class SLL, define a method delete_between_nodes() to delete specified element from the list.

12. In class SLL, implement iterator for SLL to access all the elements of the list in a sequence.

No comments:

Post a Comment

Recursion in DSA using Python

Follow me If you want to understand with  Graphical Representation   click on it. You can find the explanatory video at the bottom of this p...