Example #1
0
 def insertStart(self, data):
     newNode = Node(data)
     if not self.head:
         self.head = newNode
     else:
         newNode.nextNode = self.head
         self.head = newNode
Example #2
0
 def insertStart(self,data):
     
     newNode = Node(data);
     
     if not self.head :
         self.head = newNode;
     else:
         newNode.nextNode = self.head;
         self.head = newNode;
Example #3
0
    def insertStart(self, data):
        newNode = Node(data);
        self.counter += 1;

        if not self.head:
            self.head = newNode;
        else:
            newNode.nextNode = self.head;
            self.head = newNode;
Example #4
0
    def insertStart(self, data):  #O(1)

        self.counter += 1
        newNode = Node(data)

        if not self.head:  # If it is a first element
            self.head = newNode
        else:
            newNode.nextNode = self.head
            self.head = newNode