defadd(self,item): temp = Node(item) temp.setNext(self.head) self.head = temp defsize(self): current = self.head count = 0 while current != None: count = count + 1 current = current.getNext() return count defsearch(self,item): current = self.head found = False while current != Noneandnot found: if current.getData() == item: found = True else: current = current.getNext()
return found
defremove(self,item): current=self.head previous=None found = False while current != Noneandnot 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())
defadd(self,item): temp = Node(item) temp.setNext(self.head) self.head = temp defsize(self): current = self.head count = 0 while current != None: count = count + 1 current = current.getNext() return count defsearch(self,item): current = self.head found = False stop = False while current != Noneandnot found andnot stop: if current.getData() == item: found = True else: if current.getData() > item: stop = True else: current = current.getNext()
return found defadd(self,item): current = self.head previous = None stop = False while current != Noneandnot stop: if current.getData() > item: stop = True else: previous = current current = current.getNext()