1. Engineering
  2. Computer Science
  3. 1 5 points below is part of the definition of...

Question: 1 5 points below is part of the definition of...

Question details

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. (Dont just make changes above, rewrite the new version below.)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution