Question: Objective: In this assignment, you will implement and perform basic operations on a singly linked list. The goal is to reinforce your understanding of how

Objective:
In this assignment, you will implement and perform basic operations on a singly linked list. The
goal is to reinforce your understanding of how linked lists work and to practice manipulating
nodes.
Tasks:
1.(10 points) Node Class:
- Implement a `Node` class that contains:
- An integer `data`.
- A pointer/reference to the next `Node`.
2.(20 points) Linked List Class:
- Implement a `LinkedList` class that contains:
- A pointer/reference to the `head` node of the list (initialized as `None`).
3.(15 points) Insert at Head:
- Implement a method `insert_at_head(data)` that inserts a new node with the given `data` at
the beginning of the list.
4.(15 points) Insert at Tail:
- Implement a method `insert_at_tail(data)` that inserts a new node with the given `data` at the
end of the list.
5.(15 points) Delete a Node:
- Implement a method `delete_node(data)` that searches for the first occurrence of a node
with the specified `data` and deletes it from the list. If the node does not exist, return a message
indicating this.
6.(10 points) Display the List:
- Implement a method `display()` that prints out all the elements in the linked list in order.
7.(15 points) Search for an Element:
- Implement a method `search(data)` that returns `True` if the given `data` is present in the list
and `False` otherwise.
Bonus Task (Optional -10 points):
- Implement a method `reverse()` that reverses the linked list in place.
---
Submission Instructions:
- Submit your `LinkedList` class implementation along with test cases that demonstrate the
functionality of each operation.
- Make sure to comment your code and explain each method.
- Provide output screenshots of the test cases.
Grading Criteria:
- Correctness of implementation : 50 points
- Proper use of linked list operations : 20 points
- Code readability and comments : 20 points
- Test cases and output screenshots : 10 point

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!