Question: Need help, CS 222 Data Structure python 3.6 63-bit. from node import Node class OrderedList: def __init__(self): self.head = None def isEmpty(self): return self.head ==

Need help, CS 222 Data Structure python 3.6 63-bit.
 Need help, CS 222 Data Structure python 3.6 63-bit. from node
from node import Node
class OrderedList:
def __init__(self):
self.head = None
def isEmpty(self):
return self.head == None
def length(self):
current = self.head
count = 0
while current != None:
count += 1
current = current.getNext()
return count
def __str__(self):
msg = ""
current = self.head
while current != None:
msg += str(current.getData()) + " "
current = current.getNext()
return msg
def remove(self, item):
current = self.head
previous = None
found = False
while not found:
if current.getData() == item:
found = True
else:
previous = current
current = current.getNext()
if previous == None:
self.head = current.getNext()
else:
previous.setNext(current.getNext())
def search(self, item):
current = self.head
found = False
stop = False
while current != None and not found and not stop:
if current.getData() == item:
found = True
else:
if current.getData() > item:
stop = True
else:
current = current.getNext()
return found
def add(self, item):
current = self.head
previous = None
stop = False
while current != None and not stop:
if current.getData() > item:
stop = True
else:
previous = current
current = current.getNext()
temp = Node(item)
if previous == None:
temp.setNext(self.head)
self.head = temp
else:
temp.setNext(current)
previous.setNext(temp)

CS 222 01 Chapter 03 Algorithm Design Due: Friday, October 26, 2018 Use the OrderedList class for this assignment. Design an algorithm for the following methods for the OrderedList class: index(item)- returns the position of item in the list. It needs the item and returns the index. Assume the list has at least one item pop(pos)-removes and returns the item at position pos. It needs the position and returns the item. Assume the item is in the list

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!