[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-697947-105":59,"doc-detail-697947-en":130,"doc-similar-697947":162},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","linked-list-in-python-lecture-4-implementation","Linked List in Python - Lecture 4 - Implementation","","Lecture (4) focuses on implementing a linked list in Python for a Data Structure Lab class (Second). It explains the concept of linked lists as a linear structure of interconnected nodes, then builds a Node class and a LinkedList class using Python classes. Covered operations include insertion at the beginning, at a specific index, and at the end, plus removing a node by data, computing the list size, and printing all node contents by traversal.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":20,"@type":76,"position":81},"https://docshare.wps.com/document/exam/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/linked-list-in-python-lecture-4-implementation/697947/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/linked-list-in-python-lecture-4-implementation/697947.png","ImageObject",300,407,{"name":92,"@type":93},"bocahgabuttt","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-23","2026-11-12",true,{"@type":102,"interactionType":103,"userInteractionCount":19},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is a linked list in Python and how is it organized?","Question",{"text":112,"@type":113},"A linked list is a linear data structure made of nodes connected to each other. Each node stores data and a link (reference) to another node, and the head allows accessing elements.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do you insert a node at the beginning of a linked list?",{"text":117,"@type":113},"You create a new node with the given data. If the list is empty, the new node becomes the head; otherwise, the new node’s next reference points to the current head and then becomes the new head.",{"name":119,"@type":110,"acceptedAnswer":120},"How does insertion at a specific index work, and what happens if the index is invalid?",{"text":121,"@type":113},"You start from the head and traverse using a position counter until the node before the target index is found. If the index is zero, you insert at the beginning; if traversal reaches None, it prints “Index not present” instead of inserting.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},697947,1794446273,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":19,"category_name":20,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":19,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":129,"read_time":144,"preview_page_count":19,"preview_urls":145},962094248839,"https://ap-avatar.wpscdn.com/davatar_994ba38a5ba835b3df7d355c54d3ed8d","كــــــــلــيــة الــــعــلــومقــســــــــــم الانـــظــــمــــة الــــطـبـيـة الـــذكــــــيـــة  \nIntelligent Medical Systems Department  \nLecture: (4) Linked List in Python  \nSubject: Data Structure Lab.  \nClass: Second  \nLecturer: Asst. Prof. Mehdi Ebady Manaa  \nAsst. Lec. Sajjad Ibrahim Ismael  \nlinked list  \nin this Lecture, we will learn about the implementation of a linked list in Python. To implement the linked list in Python, we will use classes in Python. we know that a linked list consists of nodes and nodes have two elements [i.e. data](i.e. data) and a reference to another node. Let’s implement the node first.  \nWhat is Linked List in Python  \nA linked list is a type of linear data structure similar to arrays. It is a collection of nodes that are linked with each other. A node contains two things first is data and second is a link that connects it with another node. Below is an example of a linked list with four nodes and each node contains character data and a link to another node. Our first node is where head points and we can access all the elements of the linked list using the head.  \nCreating a linked list in Python  \nIn this LinkedList class, we will use the Node class to create a linked list. In this class, we have an   init   method that initializes the linked list with an empty head. Next, we have created an insertAtBegin() method to insert a node at the beginning of the linked list, an insertAtIndex() method to insert a node at the given index of the linked list, and insertAtEnd() method inserts a node at the end of the linked list. After that, we have the remove_node() method which takes the data as an argument to delete that node. In the remove_node() method we traverse the linked list if a node is present equal to data then we delete that node from the linked list. Then we have the sizeOfLL() method to get the current size of the linked list and the last  \nmethod of the LinkedList class is printLL() which traverses the linked list and prints the data of each node.  \nCreating a Node Class  \nWe have created a Node class in which we have defined a   init   function to initialize the node with the data passed as an argument and a reference with None because if we have only one node then there is nothing in its reference.  \nclass Node:  \ndef   init  (self , data): [self](self.data = data)[.data](self.data = data)[ =](self.data = data)[ data](self.data = data)[ ](self.data = data)[self](self.next = None)[.](self.next = None)[next](self.next = None)[ =](self.next = None)[ None](self.next = None)  \nInsertion in Linked List  \nInsertion at Beginning in Linked List  \nThis method inserts the node at the beginning of the linked list. In this method, we create a new_node with the given data and check if the head is an empty node or not if the head is empty then we make the new_node as head and return else we insert the head at the next new_node and make the head equal to new_node.  \ndef insertAtBegin (self, data):  \nnew_node = Node(data)  \nif self.head is None: self.head = new_node return  \nelse: [new_node.](new_node.next = self.head)[next](new_node.next = self.head)[ =](new_node.next = self.head)[ self](new_node.next = self.head)[.head](new_node.next = self.head)[ ](new_node.next = self.head)[self](self.head = new_node)[.head](self.head = new_node)[ =](self.head = new_node)[ new_node](self.head = new_node)  \nInsert a Node at a Specific Position in a Linked List  \nThis method inserts the node at the given index in the linked list. In this method, we create a new_node with given data , a current_node that equals to the head, and a counter ‘position’ initializes with 0. Now, if the index is equal to zero it means the node is to be inserted at begin so we called insertAtBegin() method else we run a while loop until the current_node is not equal to None or (position+1) is not equal to the index we have to at the one position back to insert at a given position to make the linking of nodes and in each iteration, we inc","cbCaijBZslZVeEPJ","https://ap.wps.com/l/cbCaijBZslZVeEPJ","pdf",423592,13,"English","# What is Linked List in Python\n# Creating a linked list in Python\n## LinkedList class methods\n# Creating a Node Class\n# Insertion in Linked List\n## Insertion at Beginning\n## Insertion at a Specific Position\n## Insertion in Linked List at End\n# Removing and Printing","[{\"question\":\"What is a linked list in Python and how is it organized?\",\"answer\":\"A linked list is a linear data structure made of nodes connected to each other. Each node stores data and a link (reference) to another node, and the head allows accessing elements.\"},{\"question\":\"How do you insert a node at the beginning of a linked list?\",\"answer\":\"You create a new node with the given data. If the list is empty, the new node becomes the head; otherwise, the new node’s next reference points to the current head and then becomes the new head.\"},{\"question\":\"How does insertion at a specific index work, and what happens if the index is invalid?\",\"answer\":\"You start from the head and traverse using a position counter until the node before the target index is found. If the index is zero, you insert at the beginning; if traversal reaches None, it prints “Index not present” instead of inserting.\"}]","Linked List in Python - Lecture 4 - Implementation | PDF",33,[146,150,154,158],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/9a7a23aed30ef0410d55dd9f9328d5f3.webp",983,1272,{"page_no":14,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/c3cd47f69b8e460ad4b63db1f6d40bbf.webp",982,1270,{"page_no":81,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/5fcadfa46b0d8e3610dc01e0c502d68d.webp",981,1269,{"page_no":19,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/b06ec7fe3ac984b077f5b92111933f1e.webp",980,1268,{"list":163,"token":66},[164,170,176,182,188,194,200,206,212,218],{"doc_id":165,"doc_title":166,"file_type":137,"home_preview_img_url":167,"slug":168,"view_count":44,"category_name":20,"create_tm":169},685668,"C++ Linked Lists - Review - List Operations and Traversal","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000175845/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=IJo2xoqnC58FG7gfKP0mpgAzG7g%3D","c-linked-lists-review-list-operations-and-traversal",1794016536,{"doc_id":171,"doc_title":172,"file_type":137,"home_preview_img_url":173,"slug":174,"view_count":52,"category_name":20,"create_tm":175},685768,"CS 2351 Data Structures - Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000198125/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=K1LuwItlyomB9OxjfVpCN3P%2BrxI%3D","cs-2351-data-structures-linked-lists",1794017950,{"doc_id":177,"doc_title":178,"file_type":137,"home_preview_img_url":179,"slug":180,"view_count":19,"category_name":20,"create_tm":181},697940,"Doubly Linked Lists - Part 10 - Doubly Linked Lists and Java Collections","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010136498/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=QklRDtxgIIGZmepN7qYzfo8AeMQ%3D","doubly-linked-lists-part-10-doubly-linked-lists-and-java-collections",1794446070,{"doc_id":183,"doc_title":184,"file_type":137,"home_preview_img_url":185,"slug":186,"view_count":81,"category_name":20,"create_tm":187},655747,"Lab - 09 - Working with Deployment Diagram","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229974776391/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=Cu%2FPYyePzbv2ImbEVtQ4FHQyT%2Fg%3D","lab-09-working-with-deployment-diagram",1792963548,{"doc_id":189,"doc_title":190,"file_type":137,"home_preview_img_url":191,"slug":192,"view_count":52,"category_name":20,"create_tm":193},685729,"Chapter 14 Linked Lists - Chapter 14 - Operations and Implementations of Singly Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000185871/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=ObNw9ut4EAD7rWxTH2sNrBBoO54%3D","chapter-14-linked-lists-chapter-14-operations-and-implementations-of-singly-linked-lists",1794017196,{"doc_id":195,"doc_title":196,"file_type":137,"home_preview_img_url":197,"slug":198,"view_count":29,"category_name":20,"create_tm":199},697956,"Linked List - Lecture 23-24 - Notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010142265/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=siyjng9XY52dt4G9bKEsJ1Wfydc%3D","linked-list-lecture-23-24-notes",1794446335,{"doc_id":201,"doc_title":202,"file_type":137,"home_preview_img_url":203,"slug":204,"view_count":39,"category_name":20,"create_tm":205},685761,"Singly-Linked List Class - Exam 1 - Review and HW5 Card Game Efficiency","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999691124/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=hFPRXfS%2FPyTXKO%2Bpp5AXlqZ6sN0%3D","singly-linked-list-class-exam-1-review-and-hw5-card-game-efficiency",1794017629,{"doc_id":207,"doc_title":208,"file_type":137,"home_preview_img_url":209,"slug":210,"view_count":39,"category_name":20,"create_tm":211},685774,"UNIT 2 - Lists, Dictionaries And Sets","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203839/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=4yawoNUnrPuNTGlJMa0ECo6C4nE%3D","unit-2-lists-dictionaries-and-sets",1794018222,{"doc_id":213,"doc_title":214,"file_type":137,"home_preview_img_url":215,"slug":216,"view_count":81,"category_name":20,"create_tm":217},732882,"Linked Lists in MIPS - MIPS Implementation, Recursive Functions, ISA and x86 vs MIPS Comparison","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031413521/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=hWdhYq%2BrFQ2Ae3b16dhnIWYpmi8%3D","linked-lists-in-mips-mips-implementation-recursive-functions-isa-and-x86-vs-mips-comparison",1795382683,{"doc_id":219,"doc_title":220,"file_type":137,"home_preview_img_url":221,"slug":222,"view_count":223,"category_name":20,"create_tm":224},203683,"Crush the CKA Exam","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229882942258/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796167619&Signature=aVfy2E87Ii12tvsUDjyzPtMemRg%3D","crush-the-cka-exam",17,1788562565]