[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-732877-105":59,"doc-detail-732877-en":130,"doc-similar-732877":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-data-structures-linked-lists","Linked Data Structures - Linked Lists","","Linked Lists introduces a linear data structure where nodes store data and reference the next node, with a front (head) pointer to the first element. The material explains how linked lists are represented in memory, how references work for tracing and debugging, and how to write general operations such as inserting at the front and printing list contents. It also compares linked lists with arrays, focusing on contiguity, memory growth/shrink behavior, access time, and trade-offs between time and space.",{"@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":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/linked-data-structures-linked-lists/732877/",{"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-data-structures-linked-lists/732877.png","ImageObject",300,407,{"name":92,"@type":93},"Anna Hans","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-27","2026-11-22",true,{"@type":102,"interactionType":103,"userInteractionCount":81},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is a linked list, and what roles do nodes and the front pointer play?","Question",{"text":112,"@type":113},"A linked list is a linear structure where nodes hold data and link to other nodes. The list keeps a reference to the first node, called the front (or head).","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"Why is tracing useful when writing or debugging linked-structure code?",{"text":117,"@type":113},"Linked structures can become tangled because references move from node to node. Tracing by hand with diagrams clarifies how pointers change and prevents misunderstandings about reference updates.",{"name":119,"@type":110,"acceptedAnswer":120},"How do linked lists differ from arrays in memory layout and access?",{"text":121,"@type":113},"Arrays require contiguous memory, while linked lists can place nodes anywhere in memory since each node references the next one. Arrays can immediately access the nth element, but linked lists must follow n pointers to reach it.","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},732877,1795382677,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":81,"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},5909892332657,"https://ap-avatar.wpscdn.com/davatar_994ba38a5ba835b3df7d355c54d3ed8d","LINKED DATA STRUCTURES  \nLinked Lists  \nA linked list is a structure in which objects refer to the same kind of object, and where:  \n􀀏 the objects, called nodes , are linked in a linear sequence.  \n􀀏 we keep a reference to the 􀀌rst node of the list (called the \\front\" or \\head\") .  \nThe nodes are used to store data. For example, here is a class for nodes ina linked list of ints:  \npublic class IntNode { public int value;  \npublic IntNode link;  \npublic IntNode(int v) { value = v; }}  \nNote: having public instance variables is not as bad here as it might 􀀌rst look. Why?  \nDrawing a linked list  \nThe next slide shows in detail how memory might look for a linked list containing 5 nodes.  \n\n| Assume we have a class LExample whose main builds a linked list for front to refer to.\u003Cbr>main:9 LExample \u003Cbr>IntNode front  x88  | Static area not of interest in this example. |  |  |  |  |  |  |  |  |  |  |  |  |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n|  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n|  |  | xAE |  | IntNode |  |  | x7F |  | IntNode |  |  |  |  |\n|  | int value 98\u003Cbr>|  |  |  |  | \u003Cbr>int value  161 \u003Cbr>IntNode link |  |  |  | |  |  |  |\n|  | IntNode link |  |  |  |  null   |  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |  |  | xAE |  |  |  |\n|  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n|  | |  |  |  |  | xD0\u003Cbr>IntNode\u003Cbr>int value  14  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  | IntNode link |  |  |  | x57 |  |  |  |\n|  | x88 IntNode\u003Cbr>\u003Cbr>int value  -31  |  |  |  |  |  |  |  |  |  |  |  |  |\n|  | IntNode link  xD0   |  |  |  |  |  |  |  |  |  |  |  |  |\n\nA simpler picture  \nfront  \nWhen drawing such diagrams, always be careful to `anchor' the references clearly, i.e. , to show where they are stored.  \nNote that there are several conventions for drawing a null reference, including:  \nPreferred: Not as nice:  \nTracing  \nIt's easy for linked structures to get all tangled up, so you will have to develop some new debugging skills for working with them .  \nWhen writing, debugging, or understanding code with linked structures, it is extremely useful to trace by hand, using diagrams.  \nExercise: Trace this code.  \npublic class Example {  \npublic static void main(String[] args) {  \n// Make a variable to refer to the list,  \n// and put one element into the list .  \nIntNode front = new IntNode(95);  \n// Put another element into the list  \nIntNode temp = new IntNode(104);  \n[temp.link = front](temp.link = front);  \nfront = temp;  \n// We can chain together dots:  \nSystem.out.println([front.link.value](front.link.value) ); // 95}  \n}  \nQuestions and Exercises  \n􀀏 What happens if we repeat the 3 lines \\Put another : : :\" several times, using a di􀀋erent integer each time?  \n􀀏 Suppose you want to write a general method that inserts a new element at the front of a linked list of IntNodes, for use in the example code. What header would you use? Have you considered the case where the list is empty?  \n􀀏 Write your insert method.  \n􀀏 Write a general method that prints out the contents of a linked list of IntNodes.  \n􀀏 Write a test driver for your two methods and use it to test them .  \n􀀏 Think up other methods to practice using linked lists.  \nHints for working with linked structures  \n􀀏 Trace your code by hand, using pictures, as you write it.  \n􀀏 If you are ever unsure of what some code does to references, make up fake memory addresses for the references and treat them like ordinary integers.  \n􀀏 Every time you write a line like this:  \nblah.bloop  \nto follow a reference, be sure the reference (in this case blah) is not null. Either (1) use an if , or (2) be sure that the reference cannot possibly be null in that context, and assert that fact in a comment.  \nLinked Lists vs Arrays  \nArrays are contiguous  \n􀀏 In an array, the elements have to be in a contiguous (connected and sequential) portion of memory.  \n􀀏 Memory immediately next to the array may already be in use for something else.  \n􀀏 So prog","cbCaic4MVAJCKcRj","https://ap.wps.com/l/cbCaic4MVAJCKcRj","pdf",67660,18,"English","# Linked Lists\n## Drawing a linked list\n## Tracing and debugging linked structures\n## Linked Lists vs Arrays\n## Which is better?","[{\"question\":\"What is a linked list, and what roles do nodes and the front pointer play?\",\"answer\":\"A linked list is a linear structure where nodes hold data and link to other nodes. The list keeps a reference to the first node, called the front (or head).\"},{\"question\":\"Why is tracing useful when writing or debugging linked-structure code?\",\"answer\":\"Linked structures can become tangled because references move from node to node. Tracing by hand with diagrams clarifies how pointers change and prevents misunderstandings about reference updates.\"},{\"question\":\"How do linked lists differ from arrays in memory layout and access?\",\"answer\":\"Arrays require contiguous memory, while linked lists can place nodes anywhere in memory since each node references the next one. Arrays can immediately access the nth element, but linked lists must follow n pointers to reach it.\"}]","Linked Data Structures - Linked Lists | PDF",45,[146,150,154,158],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/6661f0c914f56976c4cce21ecd89f0ef.webp",983,759,{"page_no":14,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/2a995b3b6327645d4d77821c52324357.webp",982,758,{"page_no":81,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/47bae84e7e1e75d182ed211acef697b6.webp",981,757,{"page_no":19,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/ad203adf72ce218aa474c59b328ed01e.webp",980,756,{"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":81,"category_name":30,"create_tm":169},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=1796111999&Signature=o1%2BByYLmdRttPkW4V%2B5hWZFj3Sw%3D","unit11-linked-lists",1795382671,{"doc_id":171,"doc_title":172,"file_type":137,"home_preview_img_url":173,"slug":174,"view_count":81,"category_name":30,"create_tm":175},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=1796111999&Signature=aiHC5ieA60wPK9SHR0ffCqIoeW0%3D","singly-linked-lists-in-c-introduction-and-traversal-example",1795382670,{"doc_id":177,"doc_title":178,"file_type":137,"home_preview_img_url":179,"slug":180,"view_count":81,"category_name":30,"create_tm":181},685724,"LINKED LISTS - Chapter 3 - overview","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000182527/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=krHIRlOED33cc0NX5TT2jwbftJg%3D","linked-lists-chapter-3-overview",1794016986,{"doc_id":183,"doc_title":184,"file_type":137,"home_preview_img_url":185,"slug":186,"view_count":24,"category_name":30,"create_tm":187},685762,"Linked List - Course 13004700 Part-2","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999691129/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=jK2tAKMHRckPrfhTux%2FhMvButgM%3D","linked-list-course-13004700-part-2",1794017631,{"doc_id":189,"doc_title":190,"file_type":137,"home_preview_img_url":191,"slug":192,"view_count":81,"category_name":30,"create_tm":193},732881,"CS 15 - LinkedLists Lab","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031413517/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=8WV9ECTFVlrd2uYQNzZsAL8UVaM%3D","cs-15-linkedlists-lab",1795382679,{"doc_id":195,"doc_title":196,"file_type":137,"home_preview_img_url":197,"slug":198,"view_count":24,"category_name":30,"create_tm":199},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=1796111999&Signature=eCteKXgRQmxhCYsGpIVUP%2BCDoIo%3D","chapter-4-linked-lists-41-singly-linked-lists-or-chains",1794017203,{"doc_id":201,"doc_title":202,"file_type":137,"home_preview_img_url":203,"slug":204,"view_count":24,"category_name":30,"create_tm":205},685726,"L6b - Linked List Variations - Lecture 6b","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000185855/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=cyah91ewrAIZwwhrphvMUYq%2BYOg%3D","l6b-linked-list-variations-lecture-6b",1794017196,{"doc_id":207,"doc_title":208,"file_type":137,"home_preview_img_url":209,"slug":210,"view_count":34,"category_name":30,"create_tm":211},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=1796111999&Signature=6LBqbwvYA2WebmWgoN%2B%2Ff0P6jG8%3D","lecture-five-linked-list-structure",1794017204,{"doc_id":213,"doc_title":214,"file_type":137,"home_preview_img_url":215,"slug":216,"view_count":19,"category_name":30,"create_tm":217},685767,"Implementation of Linked List - Lecture 7 - In C++","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000198089/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=ya8NyMqRODvoBewizBtiMCfZ8MM%3D","implementation-of-linked-list-lecture-7-in-c",1794017950,{"doc_id":219,"doc_title":220,"file_type":137,"home_preview_img_url":221,"slug":222,"view_count":24,"category_name":30,"create_tm":223},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=1796111999&Signature=evgUSj7gHf4miXp%2FzO9l47PWgYE%3D","linked-lists-introduction-properties-advantages-disadvantages-and-types",1794016969]