[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-782752-105":59,"doc-detail-782752-en":128,"doc-similar-782752":160},{"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":64,"keywords":65,"description":66,"schema_data":67,"social_meta":121,"head_meta":123,"extra_data":125,"updated_unix":127},105,"en","10-linkedlist","","Lecture 10 of Principles of Imperative Computation presents linked lists as nodes containing data and pointers to successors, showing how they support flexible stack and queue implementations. It contrasts easy insertion and deletion with linear-time access to interior elements, explains recursive struct definitions and NULL pointers, and distinguishes concrete lists from abstract interfaces. The lecture also defines list segments by inclusive starts and exclusive ends, then describes recursive and iterative pointer traversal for testing whether a segment exists.",{"@graph":68,"@context":120},[69,83,103],{"@type":70,"itemListElement":71},"BreadcrumbList",[72,76,78,81],{"item":73,"name":74,"@type":75,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":77,"name":9,"@type":75,"position":14},"https://docshare.wps.com/document/",{"item":79,"name":30,"@type":75,"position":80},"https://docshare.wps.com/document/technology/",3,{"item":82,"name":64,"@type":75,"position":19},"https://docshare.wps.com/document/10-linkedlist/782752/",{"url":82,"name":64,"@type":84,"image":85,"author":90,"headline":64,"publisher":93,"fileFormat":96,"inLanguage":63,"description":66,"dateModified":97,"datePublished":97,"encodingFormat":96,"isAccessibleForFree":98,"interactionStatistic":99},"DigitalDocument",{"url":86,"@type":87,"width":88,"height":89},"https://docshare.wps.com/thumbnails/10-linkedlist/782752.png","ImageObject",300,407,{"name":91,"@type":92},"noah","Person",{"url":73,"name":94,"@type":95},"DocShare","Organization","application/pdf","2026-12-03",true,{"@type":100,"interactionType":101,"userInteractionCount":14},"InteractionCounter",{"@type":102},"ViewAction",{"@type":104,"mainEntity":105},"FAQPage",[106,112,116],{"name":107,"@type":108,"acceptedAnswer":109},"How is a linked list structured?","Question",{"text":110,"@type":111},"Each node stores a data element and a pointer to the next node. A NULL pointer can mark the end of the list.","Answer",{"name":113,"@type":108,"acceptedAnswer":114},"What are the main trade-offs between linked lists and arrays?",{"text":115,"@type":111},"Linked lists make insertion and deletion convenient, while accessing an interior element usually takes O(n) time. Arrays provide indices but have fixed size.",{"name":117,"@type":108,"acceptedAnswer":118},"How does the lecture define and check a list segment?",{"text":119,"@type":111},"A segment runs from an inclusive start node to an exclusive end node. Following next pointers from the start checks whether the end can be reached.","https://schema.org",{"og:url":82,"og:type":122,"og:title":64,"og:site_name":94,"og:description":66},"article",{"robots":124,"canonical":82},"index,follow",{"doc_id":126,"site_id":62},782752,1796313805,{"code":4,"msg":5,"data":129},{"doc_id":126,"user_id":130,"nickname":91,"user_avatar":131,"doc_module":4,"category_id":29,"category_name":30,"doc_title":64,"doc_description":66,"doc_content":132,"file_id":133,"file_url":134,"file_type":135,"file_size":136,"view_count":14,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":137,"language":138,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":139,"faqs":140,"seo_title":141,"seo_description":66,"update_tm":127,"read_time":142,"preview_page_count":19,"preview_urls":143},1099529839121,"https://ap-avatar.wpscdn.com/davatar_994ba38a5ba835b3df7d355c54d3ed8d","Lecture 10  \nLinked Lists  \n15-122: Principles of Imperative Computation (Spring 2017) Frank Pfenning, Rob Simmons, André Platzer  \n1 Introduction  \nIn this lecture we discuss the use of linked lists to implement the stack and queue interfaces that were introduced in the last lecture. The linked list implementation of stacks and queues allows us to handle lists of any length.  \nThis ﬁts as follows with respect to our learning goals:  \nComputational Thinking: We discover that arrays contain implicit information, namely the indices of elements, which an be made explicit asthe addresses of the nodes of a linked list. We also encounter the notion of trade-off, as arrays and linked lists have different advantagesand drawbacks and yet achieve similar purposes.  \nAlgorithms and Data Structures: We explore linked lists, a data structure used pervasively in Computer Science, and examine some basic algorithms about them.  \nProgramming: We see that programming algorithms for linked lists can be tricky, which exposes once more the power of stating and checking invariant. We use linked lists to implement stacks and queues.  \n2 Linked Lists  \nLinked lists are a common alternative to arrays in the implementation of data structures. Each item in a linked list contains a data element of some type and a pointer to the next item in the list. It is easy to insert and delete elements in a linked list, which are not natural operations on arrays, since arrays have a ﬁxed size. On the other hand access to an element in the middle of the list is usually O (n), where n is the length of the list.  \nLECTURE NOTES 􀀍c Carnegie Mellon University 2017  \nAn item in a linked list consists of a struct containing the data element and a pointer to another linked list. In C0 we have to commit to the typeof element that is stored in the linked list. We will refer to this data as having type elem, with the expectation that there will be a type deﬁnition elsewhere telling C0 what elem is supposed to be. Keeping this in mind ensures that none of the code actually depends on what type is chosen. These considerations give rise to the following deﬁnition:  \n1 struct list_node {  \n2 elem data;  \n3 struct list_node * next; 4 };  \n5 typedef struct list_node list;  \nThis deﬁnition is an example of a recursive type. A struct of this type contains a pointer to another struct of the same type, and so on. We usually use the special element of type t *, namely NULL, to indicate that we have reached the end of the list. Sometimes (as will be the case for our use of linked lists in stacks and queues), we can avoid the explicit use of NULL and obtain more elegant code. The type deﬁnition is there to create the typename list, which stands for struct list_node, so that a pointer to a list node will be list * . We could also have written these two statements in the other order, to make better use of the type deﬁnition:  \n1 typedef struct list_node list;  \n2 struct list_node {  \n3 elem data;  \n4 list * next; 5 };  \nThere are some restriction on recursive types. For example, a declaration such as  \n1 struct infinite {  \n2 int x;  \n3 struct infinite next; 4 }  \nwould be rejected by the C0 compiler because it would require an inﬁnite amount of space. The general rule is that a struct can be recursive, but the recursion must occur beneath a pointer or array type, whose values are addresses. This allows a ﬁnite representation for values of the struct type.  \nWe don't introduce any general operations on lists; let's wait and see what we need where they are used. Linked lists as we use them here are  \na concrete type which means we do not construct an interface and a layer of abstraction around them. When we use them we know about and exploit their precise internal structure. This is in contrast to abstract types such as queues or stacks whose implementation is hidden behind an interface, exporting only certain operations. This limits what clients can do, but it allows the author of a library ","cbCaioV22dCWIy9a","https://ap.wps.com/l/cbCaioV22dCWIy9a","pdf",651569,18,"English","# Introduction\n# Linked Lists\n# List segments","[{\"question\":\"How is a linked list structured?\",\"answer\":\"Each node stores a data element and a pointer to the next node. A NULL pointer can mark the end of the list.\"},{\"question\":\"What are the main trade-offs between linked lists and arrays?\",\"answer\":\"Linked lists make insertion and deletion convenient, while accessing an interior element usually takes O(n) time. Arrays provide indices but have fixed size.\"},{\"question\":\"How does the lecture define and check a list segment?\",\"answer\":\"A segment runs from an inclusive start node to an exclusive end node. Following next pointers from the start checks whether the end can be reached.\"}]","10-linkedlist | PDF",45,[144,148,152,156],{"page_no":8,"url":145,"width":146,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/34e141e39ad3a416d9a79edafd4c8875.webp",983,1272,{"page_no":14,"url":149,"width":150,"height":151},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/73c29ef8f9be4f318a72bf5fd9e0112d.webp",982,1270,{"page_no":80,"url":153,"width":154,"height":155},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/79261b2a1c27a80d7c200f4132281439.webp",981,1269,{"page_no":19,"url":157,"width":158,"height":159},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-12-03/bd5239dad6078ad9765fad58c5cc18c6.webp",980,1268,{"list":161,"token":65},[162,168,174,180,186,192,198,204,210,216],{"doc_id":163,"doc_title":164,"file_type":135,"home_preview_img_url":165,"slug":166,"view_count":19,"category_name":30,"create_tm":167},732876,"Lecture 10 - Linked Lists - Lecture notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031413512/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=OvdBAXMw0%2FqzXaV7w%2Bs2xL165B0%3D","lecture-10-linked-lists-lecture-notes",1795382672,{"doc_id":169,"doc_title":170,"file_type":135,"home_preview_img_url":171,"slug":172,"view_count":44,"category_name":30,"create_tm":173},685731,"Lecture Five - Linked List Structure","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999689386/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=%2BvQagpZkH%2B0yHB7bo6qye62NnHk%3D","lecture-five-linked-list-structure",1794017204,{"doc_id":175,"doc_title":176,"file_type":135,"home_preview_img_url":177,"slug":178,"view_count":24,"category_name":30,"create_tm":179},719604,"Lecture 17 - Linked List Data Structure (Part-II) - Double Linked List - Applications and Insertion","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230023515168/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=uAHOib%2FNsCw9PjMgzbiMOjhYyy4%3D","lecture-17-linked-list-data-structure-part-ii-double-linked-list-applications-and-insertion",1795006749,{"doc_id":181,"doc_title":182,"file_type":135,"home_preview_img_url":183,"slug":184,"view_count":80,"category_name":30,"create_tm":185},732873,"Singly Linked Lists in C - Introduction and Traversal Example","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031413508/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=Ar0A43%2B6ty4bElfxWACfqj3TyzQ%3D","singly-linked-lists-in-c-introduction-and-traversal-example",1795382670,{"doc_id":187,"doc_title":188,"file_type":135,"home_preview_img_url":189,"slug":190,"view_count":34,"category_name":30,"create_tm":191},697943,"Lecture 12 Doubly Linked Lists - (with Recursion)","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230009212198/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=VkSrk8ewpO8vR1TO3uFhSF2pCi4%3D","lecture-12-doubly-linked-lists-with-recursion",1794446071,{"doc_id":193,"doc_title":194,"file_type":135,"home_preview_img_url":195,"slug":196,"view_count":24,"category_name":30,"create_tm":197},685730,"Chapter 4 Linked Lists - 4.1 Singly Linked Lists Or Chains","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000185878/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=67IzU90FbpEVfvT2EtK9LPKzS4g%3D","chapter-4-linked-lists-41-singly-linked-lists-or-chains",1794017203,{"doc_id":199,"doc_title":200,"file_type":135,"home_preview_img_url":201,"slug":202,"view_count":80,"category_name":30,"create_tm":203},732874,"Unit11-Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031780339/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=X1i%2FokfqAr%2BbHQJb9IhbN5lFUeI%3D","unit11-linked-lists",1795382671,{"doc_id":205,"doc_title":206,"file_type":135,"home_preview_img_url":207,"slug":208,"view_count":29,"category_name":30,"create_tm":209},685716,"Linked Lists - Introduction - Properties, Advantages, Disadvantages, and Types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999688533/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=UftVpDYlPpdHu6XcNMdKtGezcMo%3D","linked-lists-introduction-properties-advantages-disadvantages-and-types",1794016969,{"doc_id":211,"doc_title":212,"file_type":135,"home_preview_img_url":213,"slug":214,"view_count":24,"category_name":30,"create_tm":215},685741,"ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY - Linked list implementation - Singly linked lists - Core algorithms for traversal, counting, searching and insertion","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000186201/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=EDbaP84vqNDljRNAf68dBiOKqaI%3D","rohini-college-of-engineering-technology-linked-list-implementation-singly-linked-lists-core-algorithms-for-traversal-counting-searching-and-insertion",1794017223,{"doc_id":217,"doc_title":218,"file_type":135,"home_preview_img_url":219,"slug":220,"view_count":19,"category_name":30,"create_tm":221},685739,"Lecture 09 - C Structs and Linked Lists - Structs in C, BMP Headers, and Passing Structs to Functions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000186206/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796354339&Signature=JehGkDmzNzBDLfK5uhLDrCZvh6w%3D","lecture-09-c-structs-and-linked-lists-structs-in-c-bmp-headers-and-passing-structs-to-functions",1794017220]