Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1: (5 points) Below is part of the definition of the UndorderedList class, given in your textbook. To implement the length method (this is called
1: (5 points) Below is part of the definition of the UndorderedList class, given in your textbook. To implement the length method (this is called size in the digital version of the textbook), we counted the number of nodes in the list. An alternative strategy would be to store the number of nodes in the list as an additional piece of data in the head of the list. class UnorderedList: def init (self): self.headNone def add(self, item): temp = Node (item) temp.setNext (self.head) self.headtemp def length (self): current = self.head count0 while current != None: count count + 1 current -current.getNext() return count In the space below, rewrite the partial UnorderedList class definition to include, maintain, and use this new information. (Don't just make changes above, rewrite the new version below.)
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