Question: PYTHON 3..please help and explain.. class Node: class LinkedList: def init (self, value) def init (self) : self. value = value self, next = None

PYTHON 3..please help and explain..

PYTHON 3..please help and explain.. class Node: class LinkedList: def init (self,

class Node: class LinkedList: def init (self, value) def init (self) : self. value = value self, next = None self. head None def add(self, new) def get_next (self): new. next self. head return self. next self. head -newW def get_head (self): return self. head [5 points ] Using the class definitions above for LinkedList and Node objects write a function compare (A, B) that takes linked lists A and B as arguments and returns the following 4. -1 if A is shorter than B 1 if B 1s shorter than A 0 if the lists are the same length Your solution must not simply count the lengths of the lists and compare them, since the complexity would be proportional to the sum of the lengths of the lists Instead, the complexity of your solution must be proportional to the length of the smaller list. You do not need to use recursion

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!