Question: Implement a [slice method] for an unordered list. It takes two parameters, start and stop , and return a copy of the list starting at

Implement a [slice method] for an unordered list. It takes two parameters, start and stop, and return a copy of the list starting at the start position and going up to but not including the stop position. The original list should not be altered in any way by the slice method.

Note: The way I did it is not right!!!!!!! I am seeking a correct answer. Thank you!

class unordered class:

class Node: def __init__(self,initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self,newdata): self.data = newdata def setNext(self,newnext): self.next = newnext class unorderedlist: def __init__(self): self.head = None def isEmpty(self): return self.head == None def add(self,item): temp = Node(item) temp.setNext(self.head) self.head = temp def size(self): current = self.head count = 0 while current != None: count = count + 1 current = current.getNext() return count

.........

.........

.........

etc...

def slice(self,start,stop):

Implement a [slice method] for an unordered list. It takes two parameters,

F# 3. (10 points) Programming Exercise 19 from Chapter 4 of your textbook. The "copy" being # created here is another instance of the Unordered List class with contents as described in # Programming Exercise 19. The original list should not be altered in any way by the slice A# method. # def slice(self, start, stop): sample = [] if self.head == None: print('Empty Stack') else: current = self.head while current != None: sample.append(current.getData()) current = current.getNext() return sample copy = slice(start, stop) return print(sample[copy])| E A

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!