Linked List | Set 2 (Inserting a node)

def insert(self, data):
temp = Node(data)
temp.next = self.head
self.head = temp
def append_to_linked_list(self,new_data):
temp = self.head
new_node = Node(new_data)
while(temp):
if temp.next == None:
temp.next = new_node
return
else:
temp = temp.next
def add_at_first(self,new_data):
new_node = Node(new_data)
new_node.next= self.head
self.head = new_node
def inser_after(self,prev_node, new_data):
new_node = Node(new_data)
new_node.next = prev_node.next
prev_node.next = new_node

--

--

--

Looking for my next opportunity to make change in a BIG way

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

9 Mistakes to Avoid When Developing WordPress Plugins or Themes — Freemius

How to Install Hyperledger Fabric (for training purposes)?

Developer log #2 : introduction about MBxOC battle suit (2)

Microsoft Word Won’t Force Quit On Mac

Amazon Cloudfront

Real-time Applications and Business Transformation

GUI Deployment of IAC in the Commandeer Desktop App (Ansible and Serverless Framework)— Part 1 of 3

How to Hard Reset LG K20 Plus TP260

Hard Reset LG

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sairam Penjarla

Sairam Penjarla

Looking for my next opportunity to make change in a BIG way

More from Medium

Popular Backtracking Problems Explained Easily using Python

Popular Backtracking problems explained and solved in Python

Fractals

Choosing What to Learn Next

Getting started with Blockchain and programming it in Python