Answered step by step
Verified Expert Solution
Link Copied!

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 =

image text in transcribed

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 appropriate

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions