[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-732881-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-732881-en":130,"doc-similar-732881":161},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","cs-15-linkedlists-lab","CS 15 - LinkedLists Lab","","CS 15 LinkedLists Lab introduces linked lists as a linear data structure of interconnected Node objects rather than contiguous memory like arrays. It explains pointer-based insertion and removal, then covers using Valgrind to detect memory leaks, segfaults, and memory errors. The lab uses a Planet class (name as std::string and distance_from_sun as int) stored in a LinkedList, requiring implementation of front insertion, back insertion, and a destructor. Instructions include starter code setup and building with Makefile.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/cs-15-linkedlists-lab/732881/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/cs-15-linkedlists-lab/732881.png","ImageObject",300,407,{"name":42,"@type":43},"Blitz","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-26","2026-11-22",true,{"@type":52,"interactionType":53,"userInteractionCount":30},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"How does a linked list differ from an array in memory storage?","Question",{"text":62,"@type":63},"A linked list stores elements as Node objects connected by pointers, not in contiguous memory like an array.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"What is Valgrind used for in this lab?",{"text":67,"@type":63},"Valgrind is a debugging tool that detects memory leaks, segfaults, and other memory-related errors by instrumenting the program at runtime.",{"name":69,"@type":60,"acceptedAnswer":70},"What functions are students responsible for within the LinkedList class?",{"text":71,"@type":63},"Students implement inserting at the front, inserting at the back, and the destructor for the LinkedList that stores Planet objects.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},732881,1795382679,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":30,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":123,"language":139,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":12,"update_tm":79,"read_time":143,"preview_page_count":33,"preview_urls":144},24464137899374,"https://us-avatar.wpscdn.com/davatar_3d24733baf745e90a7e4bdd5f77d97b2","CS 15: LinkedLists Lab  \nIntroduction  \nThis week, we are working with linked lists and valgrind! Like arrays, linked lists are linear data structures which store elements.  \nAn important aspect of this data structure is that the elements of a linked list are not stored together at a contiguous location in memory; instead, a linked list is a collection of Node objects, which are linked together with pointers. That is, each Node, in addition to containing some data, contains  \n2  \na pointer to another Node. This structure makes inserting into and removing from a linked list easier than with an array, because, rather than having to shift all of the list’s elements around, we just have to create a new node and link it to the necessary existing nodes. To remove, we link necesssary nodes together and delete the desired node. Details are discussed in lecture.  \nWe will also begin to work with valgrind, a tool for debugging. It will become your best friend this semester. It can detect memory leaks, segfaults, and other errors in your program. It works by instrumenting the code of your program at runtime and then analyzing the data collected during execution to find errors. valgrind is particularly useful for finding memory-related errors, such as memory leaks and memory errors. A memory leak occurs when a program dynamically allocates memory for an object but then loses the reference to it, meaning that allocated memory is unable to be freed. On the other hand, a memory error can occur when a program incorrectly accesses memory. This can include things like trying to read from or write to memory that the program should not have access to or accessing memory that has already been freed.  \nTo use valgrind, you need to run your program with the valgrind command, followed by the name of the program you want to debug or profile. For example, to check for memory leaks in a program called planet-driver, you would run valgrind ./planet-driver (hint hint) .  \nFor the lab, we will be working with a linked list that stores Planet objects! A Planet object contains:  \n• std: string name-the name of planet  \n• int distance_from_sun-distance from the sun (in millions of miles) .  \nThe Planet class is written for you-you will be responsible for a couple of functions within the LinkedList class, including inserting at the front of the list, inserting at the back of the list, and the destructor.  \nGetting Started  \n1. You should have a cs15 directory within your home directory.  \n2. Create a lab2 directory inside cs15 and move into it.  \n3. Copy the starter code: cp /comp/15/files/lab_linkedlists/* .  \n(a) Make sure you can answer these questions:  \n1  \n2  \n3  \n4  \n5  \n6  \n7  \n8  \n3  \ni. What does the . mean?  \nii. What does the /* mean?  \n(b) If you can’t answer those questions, discuss your ideas with your classmates around you.  \n4. Remember that a good policy when programming is to write a little, compile, test, repeat.  \nPart 0: Understanding the Starter Code  \nPlanet Class  \nIn this lab, the elements we are working with will be Planets! As metioned above, a Planet object contains a name (a std::string) and a distance from the sun in millions of miles (an int) . The Planet class is completely written for you. Take a quick look at both Planet .h and Planet .cpp before continuing on.  \nLinkedList class  \nRegarding the LinkedList class, the starter code provides a complete LinkedList header file (LinkedList.h), and a partially completed driver file LinkedList .cpp. It would be well worth your time to review these files. Start with the header file. Notice the Node struct definition within the private section.  \n...  \nprivate:  \nstruct Node {  \nPlanet info ;  \nNode *next;  \nstd::string toString() { return info .toString(); };};  \n...  \nRecall that contents of a struct object are public by default. However, because this struct is defined within the private section of the LinkedList class, its fields are only accessible by way of LinkedList objects. In ","cbCaicx6eanZFVjv","https://ap.wps.com/l/cbCaicx6eanZFVjv","pdf",4364605,"English","# Introduction\n## Part 0: Understanding the Starter Code\n## Getting Started\n# The Lab\n# Compiling and Running","[{\"question\":\"How does a linked list differ from an array in memory storage?\",\"answer\":\"A linked list stores elements as Node objects connected by pointers, not in contiguous memory like an array.\"},{\"question\":\"What is Valgrind used for in this lab?\",\"answer\":\"Valgrind is a debugging tool that detects memory leaks, segfaults, and other memory-related errors by instrumenting the program at runtime.\"},{\"question\":\"What functions are students responsible for within the LinkedList class?\",\"answer\":\"Students implement inserting at the front, inserting at the back, and the destructor for the LinkedList that stores Planet objects.\"}]","CS 15 - LinkedLists Lab | PDF",25,[145,149,153,157],{"page_no":22,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/61d82993f1c5166fa6bb6a4f894d4e1e.webp",983,1272,{"page_no":26,"url":150,"width":151,"height":152},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/af7d0f62569a00fd3b00e137497e4040.webp",982,1270,{"page_no":30,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/3973c9738fd2d4d95bfb1060545bd292.webp",981,1269,{"page_no":33,"url":158,"width":159,"height":160},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-22/2336bd5059dfc138a023addab03f0244.webp",980,1268,{"list":162,"token":11},[163,169,174,180,186,192,198,204,210,216],{"doc_id":164,"doc_title":165,"file_type":137,"home_preview_img_url":166,"slug":167,"view_count":30,"category_name":29,"create_tm":168},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":170,"doc_title":171,"file_type":137,"home_preview_img_url":172,"slug":173,"view_count":30,"category_name":29,"create_tm":79},732880,"Linked List Basics - Linked List Basics - Insertion, Deletion, Navigation, and Advanced Operations","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031780344/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=4qOzk65WtlV4%2BzUC1IXiuSBFd%2Fs%3D","linked-list-basics-linked-list-basics-insertion-deletion-navigation-and-advanced-operations",{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":30,"category_name":29,"create_tm":179},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":181,"doc_title":182,"file_type":137,"home_preview_img_url":183,"slug":184,"view_count":96,"category_name":29,"create_tm":185},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":187,"doc_title":188,"file_type":137,"home_preview_img_url":189,"slug":190,"view_count":96,"category_name":29,"create_tm":191},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":193,"doc_title":194,"file_type":137,"home_preview_img_url":195,"slug":196,"view_count":33,"category_name":29,"create_tm":197},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":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":30,"category_name":29,"create_tm":203},732877,"Linked Data Structures - Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031413515/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=OqipMd%2BsHAA7Vt2ugflSdlhC8pU%3D","linked-data-structures-linked-lists",1795382677,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":105,"category_name":29,"create_tm":209},685695,"High Performance Lists in Java - JavaZone 2015 - Motivation: A Real World Example","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179383/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=qdXK76u9blTl3ptTL2tbIpWZPkc%3D","high-performance-lists-in-java-javazone-2015-motivation-a-real-world-example",1794016775,{"doc_id":211,"doc_title":212,"file_type":137,"home_preview_img_url":213,"slug":214,"view_count":33,"category_name":29,"create_tm":215},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":217,"doc_title":218,"file_type":137,"home_preview_img_url":219,"slug":220,"view_count":221,"category_name":29,"create_tm":222},347398,"PROGRAMMING IN “C” - MCA 101 - Lecture Notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229911501616/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=lVTnnMEsv9nzFMv%2FD1G3sKHj0T0%3D","programming-in-c-mca-101-lecture-notes",34,1790066783]