Day6 LinkedList Assignments
Day6 LinkedList Assignments
Objective: Define what a Linked List is and compare it with Lists/Arrays. Instructions:
• List and define the different types of Linked Lists (Singly Linked List, Doubly
Linked List, Circular Linked List).
• For each type, explain its structure, advantages, and use cases.
• The class should have attributes for storing data and the reference to the next
node.
• Test the Node class by creating a few nodes and linking them manually.
• Write a constructor for the LinkedList class to initialize the head of the list.
• Test the LinkedList class by creating a new list and adding a node to it.
Assignment 5: Insertion in Singly Linked List
• Add a method to the LinkedList class to insert a new node at the beginning
(prepend) of the list.
• Add another method to insert a new node at the end (append) of the list.
• Test the methods by inserting multiple nodes at both the beginning and end of
the list.
Assignment 6: Traversal of Singly Linked List
• Add a method to the LinkedList class to traverse the list and print all the node
values.
• Add a method to the LinkedList class to search for a specific value in the list.
• The method should return the position of the node if found, or indicate if the
value is not present.
• Test the search method with various inputs, including edge cases (e.g.,
searching in an empty list, searching for a non-existent value).
Objective: Implement methods to retrieve and update values in a Singly Linked List.
Instructions:
• Add a get method to retrieve the value of a node at a given position in the list.
• Add a set method to update the value of a node at a given position in the list.
Objective: Implement the remove method to delete a node from a Singly Linked List.
Instructions:
• Add a method to the LinkedList class to remove a node with a specific value
from the list.
• The method should handle cases where the node to be removed is at the head,
middle, or end of the list.
• Test the remove method by deleting nodes from different positions in the list.
Assignment 10: Time and Space Complexity of Singly Linked List Operations
Objective: Analyze the time and space complexity of Singly Linked List operations.
Instructions:
• Discuss scenarios where using a Linked List is more efficient than using a
List/Array.