Answered step by step
Verified Expert Solution
Question
1 Approved Answer
from __future__ import annotations from typing import Any, Optional class Node: def __init__(self, value: Any, nxt: LinkedList): self.value = value self.next = nxt LinkedList =
from __future__ import annotations
from typing import Any, Optional
class Node: def __init__(self, value: Any, nxt: LinkedList): self.value = value self.next = nxt
LinkedList = Optional[Node]
def empty_list() -> LinkedList: ...
def add(lst: LinkedList, index: int, value: Any) -> LinkedList: ...
def length(lst: LinkedList) -> int: ...
def get(lst: LinkedList, index: int) -> Any: ...
def setitem(lst: LinkedList, index: int, value: Any) -> LinkedList: ...
def remove(lst: LinkedList, index: int) -> tuple[Any, LinkedList]: ...
In a file named linked_list.py, provide a data definition for a LinkedList, whose Node class's value field can be any value. An empty list should be represented by the Python value None. Be sure to call your node class Node, so that my tests can create objects correctly. Implement the functions listed above. None of the functions should modify the list that you're given. All of the functions should return a new list. Additionally, implement the __eq equanction in your Node class. This will help with testing. Place your test cases in a file named linked_list_tests.py. Include type signatures and a docstring purpose statement as appropriateStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started