[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-732874-105":59,"doc-detail-732874-en":130,"doc-similar-732874":161},{"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","unit11-linked-lists","Unit11-Linked Lists","","CS 103 Unit 11 slides on linked lists explain the motivation for using pointer-based, dynamically allocated node structures rather than contiguous arrays. The material defines NULL pointers (and C/C++ nullptr as the C++11+ keyword), shows common uses such as representing “pointer to nothing” and error returns, and motivates careful null checks. Examples illustrate memory layout, inserting/removing values, and a BFS queue analogy. A section compares arrays vs linked lists in access speed and resizing trade-offs, then outlines typical linked list operations and C++ implementation patterns using structs/classes and a head pointer.",{"@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/unit11-linked-lists/732874/",{"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/unit11-linked-lists/732874.png","ImageObject",300,407,{"name":92,"@type":93},"Bulrr","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-26","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 does a NULL pointer mean in C/C++?","Question",{"text":112,"@type":113},"A NULL pointer has a value of 0 and represents a pointer to “nothing.” It is also commonly used as an error return value from functions that return pointers.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"Why is using linked lists more flexible than using arrays?",{"text":117,"@type":113},"Linked lists store values in separate dynamically allocated chunks and only track the head pointer, so they can grow or shrink without requiring a predetermined maximum size like arrays often do.",{"name":119,"@type":110,"acceptedAnswer":120},"How do arrays and linked lists differ for accessing the i-th element?",{"text":121,"@type":113},"Arrays support quick access to the i-th element by computing an offset from the start address. Linked lists require walking node by node because items are not contiguous in memory.","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},732874,1795382671,{"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},5909892115043,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","CS 103 Unit 11  \nLinked Lists  \nMark Redekopp  \n2  \nNULL Pointer  \n• Just like there was a null character in ASCII = ' \\0' whose value was 0 there is a NULL pointer whose value is 0  \n– Used to represent a pointer to \"nothing\"  \n– NULL is \"keyword\" you can use in C/C++ that is defined to be 0  \n– nullptr is an equivalent keyword in C++ version 11 and onward and has some advantages best explained later…  \n• Requires special compile flags, so we may default to NULL for now  \n• Used to indicate that the pointer does NOT point at valid data  \n– Nothing ever lives at address 0 of memory so we can use it to mean\"pointer to nothing\"  \n– Often used as an \"error\" return value from functions returning pointers (See [http://www.cplusplus.com/reference/cstring/strchr/](http://www.cplusplus.com/reference/cstring/strchr/) )  \n– char* ptr = strchr(\"Hello\", 'h')  \nif(ptr != NULL){ … } // it's a good pointer  \n4  \nAnalogy  \n• Natural analogy when we have a set of items that can change is to create a list  \n– Write down what you know now  \n– Can add more items later (usually to the end of the list)  \n– Remove (cross off) others when done with them  \n• Can only do this with an array if you know max size of list ahead of time (which is sometimes fine)  \n1. Do CS 103 lab  \n2. Join ACM or IEEE  \n3. Play Video Games  \n4. Watch a movie  \n5. Exercise  \n~~1. Do CS 103 lab~~  \n2. Join ACM or IEEE  \n3. Play Video Games  \n4. Watch a movie  \n5. Exercise  \n6. Eat dinner  \n5  \nBFS Queue Example  \n• The size of the BFS Queue grew and shrunk based on the data pattern  \n• But we wasted a whole LARGE array planning for the worst case  \n• It'd be great to store only what we need where our storage can grow and shrink  \n \\#   \n \\# S \\# \\#   \n \\#  \\# F   \nhead tail  \n 5   \nhead tail  \nhead tail  \n 5 1 9 0 2   \nhead tail  \n 5 1 9 0 2   \n6  \nLinked Lists  \n• A linked list stores values in separate chunks of memory (i.e. a dynamically allocated object)  \n• To know where the next one is, each one stores a pointer to the next  \n• We can allocate more or delete old ones as needed so we only use memory as needed  \n• All we do is track where the first object is (i.e. the head pointer)  \nhead  \n0x148  \n0x148 0x1c0  \n\n| 3 | 0x1c0 |\n| --- | --- |\n\n\n| 9 | 0x168 |\n| --- | --- |\n\n0x168  \n\n| 2 | 0x0 (Null) |\n| --- | --- |\n\nval next val next val next  \n7  \nLinked Lists  \n• What is the order of values in this linked list?  \n• How would you insert 6 at the front of the list?  \n• How would you remove the value 4?  \nhead  \n0x300  \n0x240  \n\n| 4 | 0x3e0 |\n| --- | --- |\n\nval  \nnext  \n0x200  \n\n| 8 | 0x0 (Null) |\n| --- | --- |\n\nval next  \n0x300  \n\n| 5 | 0x240 |\n| --- | --- |\n\nval  \nnext  \n0x3e0  \n\n| 1 | 0x200 |\n| --- | --- |\n\nval  \nnext  \n8  \nArrays vs. Linked List  \n• If we have the start address of an array can we get the i-th element quickly?  \n– Yes: start-addr + i * sizeof(data)  \n• If we have the start (head) pointer to a linked list can we find the i-th element quickly?  \n– No…Have to walk the linked list  \n– Items are NOT CONTIGUOUS  \n• Linked lists trade the ability toresize (grow/shrink) for speed of access when attempting to get a specific element  \n\\#include\u003Ciostream> using namespace std;  \nint main(){  \nint data[25]; data[20] = 7; return 0;  \n}  \ndata = 100  \n100 104 108 112 116 120  \n\n| 45 | 31 | 21 | 04 | 98 | 73 | … |\n| --- | --- | --- | --- | --- | --- | --- |\n\nMemory  \nhead  \n0x148  \n0x148 0x 1c0 0x168  \n| 3 | 0x1c0 | | 9 | 0x168 | | 2 | 0x0 (Null) |\n| --- | --- | --- | --- | --- | --- | --- | --- |\n\nval next val next val next  \n  \nLinked List  \n• Use structures/classes and pointers to make linked data structures  \n• List  \n– Arbitrarily sized collection of values  \n– Can add any number of new values via dynamic memory allocation  \n• Should always dynamically allocate Items in a linked list  \n– Usually supports following set of operations:  \n• Append (“push_back”)  \n• Prepend (“push_front”)  \n• Remove back item (“pop_back”)  \n• Remove front item (“pop_front”)  \n• Find (loo","cbCaidBjkH6953pj","https://ap.wps.com/l/cbCaidBjkH6953pj","pdf",557816,28,"English","# NULL Pointer\n# Analogy\n# BFS Queue Example\n# Linked Lists\n## Arrays vs. Linked List\n## Linked List Operations and Implementation","[{\"question\":\"What does a NULL pointer mean in C/C++?\",\"answer\":\"A NULL pointer has a value of 0 and represents a pointer to “nothing.” It is also commonly used as an error return value from functions that return pointers.\"},{\"question\":\"Why is using linked lists more flexible than using arrays?\",\"answer\":\"Linked lists store values in separate dynamically allocated chunks and only track the head pointer, so they can grow or shrink without requiring a predetermined maximum size like arrays often do.\"},{\"question\":\"How do arrays and linked lists differ for accessing the i-th element?\",\"answer\":\"Arrays support quick access to the i-th element by computing an offset from the start address. Linked lists require walking node by node because items are not contiguous in memory.\"}]","Unit11-Linked Lists | PDF",71,[146,150,153,157],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/32efe7f580305afa0e3d45a5f2cf9d55.webp",983,736,{"page_no":14,"url":151,"width":152,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/92d289086468a61f1036185cfb6e3c46.webp",982,{"page_no":81,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/32113aaae4f76ae010eda3e3f06e3123.webp",981,735,{"page_no":19,"url":158,"width":159,"height":160},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/c330e4f164026adc25b3b882bbbf9786.webp",980,734,{"list":162,"token":66},[163,169,175,181,187,193,199,205,211,217],{"doc_id":164,"doc_title":165,"file_type":137,"home_preview_img_url":166,"slug":167,"view_count":29,"category_name":30,"create_tm":168},685766,"Linked Lists - Fundamentals - Core Concepts and C++ Implementation Notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000198068/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=dZzRiuAy01Yu9DauedNtbhjpchs%3D","linked-lists-fundamentals-core-concepts-and-c-implementation-notes",1794017949,{"doc_id":170,"doc_title":171,"file_type":137,"home_preview_img_url":172,"slug":173,"view_count":19,"category_name":30,"create_tm":174},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=1796111999&Signature=7stbRYZuo3MNQpiTcEXYaXp%2BpkI%3D","lecture-09-c-structs-and-linked-lists-structs-in-c-bmp-headers-and-passing-structs-to-functions",1794017220,{"doc_id":176,"doc_title":177,"file_type":137,"home_preview_img_url":178,"slug":179,"view_count":19,"category_name":30,"create_tm":180},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=1796111999&Signature=NMuSUr0FZ%2Bb4jIZ8V5qs3mNZqx8%3D","lecture-10-linked-lists-lecture-notes",1795382672,{"doc_id":182,"doc_title":183,"file_type":137,"home_preview_img_url":184,"slug":185,"view_count":19,"category_name":30,"create_tm":186},685722,"Linked List Basics - read and practice","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000182486/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=TbXSK4%2B6Ix2hlqqfHptjqutTDfE%3D","linked-list-basics-read-and-practice",1794016978,{"doc_id":188,"doc_title":189,"file_type":137,"home_preview_img_url":190,"slug":191,"view_count":24,"category_name":30,"create_tm":192},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":194,"doc_title":195,"file_type":137,"home_preview_img_url":196,"slug":197,"view_count":81,"category_name":30,"create_tm":198},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":200,"doc_title":201,"file_type":137,"home_preview_img_url":202,"slug":203,"view_count":81,"category_name":30,"create_tm":204},711463,"Head First C - Praise","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230016239501/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=8d4q7sdxA4TeyxtTOJySinM4114%3D","head-first-c-praise",1794789698,{"doc_id":206,"doc_title":207,"file_type":137,"home_preview_img_url":208,"slug":209,"view_count":19,"category_name":30,"create_tm":210},685674,"Lecture 18 - Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999686601/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=l5SfzzMEY619NU7EbLMgg4hInDI%3D","lecture-18-linked-lists",1794016551,{"doc_id":212,"doc_title":213,"file_type":137,"home_preview_img_url":214,"slug":215,"view_count":24,"category_name":30,"create_tm":216},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":218,"doc_title":219,"file_type":137,"home_preview_img_url":220,"slug":221,"view_count":34,"category_name":30,"create_tm":222},685760,"CS62 Class 8 - Linked lists - Basic Data Structures","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000192614/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=FTE1yqlet7ErMC3OQEemIAQoeYQ%3D","cs62-class-8-linked-lists-basic-data-structures",1794017629]