Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The linked list ADT The Linked List ADT is very much like the node - based Queue ADT we studied in class. The _ _
The linked list ADT
The Linked List ADT is very much like the nodebased Queue ADT we studied in class. The init
operation is as follows:
class LList object :
def init self :
Purpose
creates an empty list
self size # how many elements in the stack
self head None # the node chain starts here ; initially empty
self tail None
A linked list is an object with the following attributes:
size This keeps track of how many values are in the list.
head This is a reference to the first node in the node chain. An empty Linked List has no node chain, which
we represent with None.
tail This is a reference to the last node in the chain. If the list is empty, this is None.
Notice that the LList attributes are protected. This helps us write test cases that would not be possible with
private attributes. Also note that the node class attributes are public. This makes their use in the LList class
a little easier. We no longer need to use the setters and getters from Chapter in which the attributes
were private.
Step 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