how to add at the beginning of Linked List code example
Example 1: linked list insertion at beginning algorithm
Step 1. Create a new node and assign the address to any node say ptr.Step 2. OVERFLOW,IF(PTR = NULL) write : OVERFLOW and EXIT.Step 3. ASSIGN INFO[PTR] = ITEMStep 4. IF(START = NULL) ASSIGN NEXT[PTR] = NULL ELSE ASSIGN NEXT[PTR] = STARTStep 5. ASSIGN START = PTRStep 6. EXIT
Example 2: how to add to beginning of linked list python
def insert_at_start(self, data):
new_node = Node(data)
new_node.ref = self.start_node
self.start_node= new_node