Insertion at the end of Linked list | Python 🐍 for Beginners
Автор: Gate Smashers
Загружено: 2024-01-04
Просмотров: 18791
Описание:
00:00 – Insertion at end
02:10 – pseudo code
👉Code for execution:
class Node:
def __init__(self, data):
self.data = data
self.next = None
Creating nodes
node1 = Node(10)
node2 = Node(20)
node3 = Node(30)
node4 = Node(40)
Connecting nodes
node1.next = node2
node2.next = node3
node3.next = node4
Adding a new node with data 50 at the end
new_node = Node(50)
head=node1
current = head
while current.next is not None:
current = current.next
current.next = new_node
A linked list is a linear data structure where each element is a separate object. The elements are not stored in contiguous memory locations, but rather as separate nodes. Each node contains a data field and a reference (or link) to the next node in the list.
To insert an element at the end of a linked list, you need to create a new node with the data you want to insert and then link it to the last node in the list.
👉Subscribe to our new channel: / @varunainashots
► Python For Beginners (Complete Playlist):
• Python for Beginners
Other Subject-wise Playlist Links:
--------------------------------------------------------------------------------------------------------------------------------------
►Computer Networks :
• Computer Networks (Complete Playlist)
►Design and Analysis of algorithms (DAA):
• Design and Analysis of algorithms (DAA)
►Database Management System:
• DBMS (Database Management system) Complete...
► Theory of Computation
• TOC(Theory of Computation)
►Artificial Intelligence:
• Artificial Intelligence (Complete Playlist)
►Computer Architecture:
• Computer Organization and Architecture (Co...
►Operating System:
• Operating System (Complete Playlist)
►Structured Query Language (SQL):
• Structured Query Language (SQL)
►Discrete Mathematics:
• Discrete Mathematics
►Compiler Design:
• Compiler Design (Complete Playlist)
►Number System:
• Number system
►Cloud Computing & BIG Data:
• Cloud Computing (Complete Course)
►Software Engineering:
• Software Engineering
►Data Structure:
• Data Structure
►Graph Theory:
• Graph Theory
►Programming in C:
• C Programming
►Digital Logic:
• Digital Logic (Complete Playlist)
► Class XI Computer Science(Full Syllabus)
• CLASS-XI Computer Science (Full Syllabus)
► Microprocessor Playlist:
• Microprocessor
---------------------------------------------------------------------------------------------------------------------------------------
Our social media Links:
► Subscribe to us on YouTube: / gatesmashers
►Subscribe to our new channel: / @varunainashots
► Like our page on Facebook: / gatesmashers
► Follow us on Instagram: / gate.smashers
► Follow us on Instagram: / varunainashots
► Follow us on Telegram: https://t.me/gatesmashersofficial
► Follow us on Threads: https://www.threads.net/@gate.smashers
--------------------------------------------------------------------------------------------------------------------------------------
►For Any Query, Suggestion or notes contribution:
Email us at: [email protected]
#python #pythonprogramming
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: