[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-685761-105":3,"detail-sidebar-cat-0-en-105":81,"doc-detail-685761-en":130,"doc-similar-685761":165},{"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":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","singly-linked-list-class-exam-1-review-and-hw5-card-game-efficiency","Singly-Linked List Class - Exam 1 - Review and HW5 Card Game Efficiency","","Study notes for Exam 1 in a Singly-Linked List class (15-121, Fall 2020). Topics cover core linked-list advantages and disadvantages versus arrays/ArrayLists, how to visualize a singly-linked list with head and null termination, and creating an empty list. It also reviews Java statements that update next references, including removal of the first node and creation of a circular linked list. Homework discussion focuses on two ways to deal cards, comparing pile.remove(0) versus pile.remove(pile.size()-1) time efficiency.",{"@graph":14,"@context":73},[15,34,56],{"@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/exam/","Exam",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/singly-linked-list-class-exam-1-review-and-hw5-card-game-efficiency/685761/",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/singly-linked-list-class-exam-1-review-and-hw5-card-game-efficiency/685761.png","ImageObject",300,407,{"name":42,"@type":43},"Valentina","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-15","2026-11-07",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",8,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What are the main advantages and disadvantages of linked lists compared to arrays/ArrayLists?","Question",{"text":63,"@type":64},"Linked lists avoid needing large contiguous memory, break arrays into smaller pieces, and can grow or shrink without copying data. They also have sequential access, making middle access slower, so arrays/ArrayLists do better at random access.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How do you represent an empty singly-linked list in this class?",{"text":68,"@type":64},"An empty linked list has the head reference equal to null (e.g., Node list = null). This differs from empty Strings or ArrayLists, where you can still query length or size and potentially add elements.",{"name":70,"@type":61,"acceptedAnswer":71},"Which is more efficient for dealing a card from a pile: pile.remove(0) or pile.remove(pile.size()-1), and why?",{"text":72,"@type":64},"pile.remove(0) is O(n), while pile.remove(pile.size()-1) is O(1). The latter is easier to code and more efficient according to the notes.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},685761,1794017629,{"code":4,"msg":82,"data":83},"success",[84,88,92,95,100,105,110,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":85,"show_sort_weight":86,"slug":87},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":89,"show_sort_weight":90,"slug":91},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":93,"slug":94},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":102,"show_sort_weight":103,"slug":104},6,"Technology",50,"technology",{"id":106,"doc_module":4,"doc_module_name":25,"category_name":107,"show_sort_weight":108,"slug":109},7,"Healthcare",40,"healthcare",{"id":55,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},"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":82,"data":131},{"doc_id":79,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":33,"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":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":80,"read_time":144,"preview_page_count":96,"preview_urls":145},13056703020460,"https://ap-avatar.wpscdn.com/avatar/be000253dac470eee5d?_k=1778207105932848923","Singly-Linked List Class  \n15-121 Fall 2020 Margaret Reid-Miller  \nExam 1 during class Thursday  \n• [Please email](Please email mrmiller@cs.cmu.edu)[ ](Please email mrmiller@cs.cmu.edu)[mrmiller@cs.cmu.edu](Please email mrmiller@cs.cmu.edu) if you will have any difficulties and need accommodations.  \n• Topics include everything except Linked Lists.  \n• Review Sessions:  \n• Sean: Today 5pm – 6pm  \n• Margaret: Wednesday during lab (attendance not required)  \n• Leah: Wednesday 5pm-6pm  \nFall 2020 15-121 (Reid-Miller) 2  \nToday  \n• Homework 5 problems and checkpoint: last day to submit was last night.  \n• Solution to problems will be posted on autolab later today.  \n• Today – Implementing a generic Linked List class  \nFall 2020 15-121 (Reid-Miller) 3  \nHow to deal cards in HW5 card game .  \n• What are two ways to deal a card from a pile?  \n• pile.remove (0) O(n)  \n• pile.remove (pile.size()-1) O(1)  \n• Which is easier to code?  \n• Which is the more efficient? The latter. Why?  \n• Never again will you get away with using remove(0) or add(0, E) if you can reframe the code to use remove and add at the end of the array list!  \nFall 2020 15-121 (Reid-Miller) 5  \nLinked Lists  \n• Advantages:  \n• Don’t need large blocks of contiguous memory.  \n• Breaks up an array into little pieces  \n• Can grow and shrink without copying data.  \n• Disadvantages:  \n• Access is sequential. Slow to access the middle of the list.  \n• What arrays/ArrayLists do well, linked list do poorly and vice versa.  \nFall 2020 15-121 (Reid-Miller) 6  \nSingly-linked list visualization  \ndata next  \na node  \nhead  \nlist  \"C\"    \n• A reference, often called the head, points to the node with the first data entry.  \n• The last node in the list contains null as its reference to the next node signifies the end of the list.  \n• How do you create an empty linked list?  \nNode list = null  \nFall 2020 15-121 (Reid-Miller) 8  \nAn empty linked list has a head reference equal to null .  \n• This is very different than Strings or ArrayLists  \n• If I have an empty String,  \n• I can still ask for its length and  \n• check if it is equal to another String.  \n• If I have an empty ArrayList,  \n• I can still ask for its size and  \n• add elements to it.  \nFall 2020 15-121 (Reid-Miller) 9  \nWhat does the following Java statement do to this linked list?  \nlist  \"A\"  \n[1.](1. list = list.next)[ list = list.next](1. list = list.next);  \nlist \"A\" \"B\" \"C\"  \nFall 2020 15-121 (Reid-Miller) 11  \nWhat does the following Java statement do to this linked list?  \nlist  \"A\"  \n[2.](2. list.next = list.next.next)[ list.next = list.next.next](2. list.next = list.next.next);  \nlist  \"A\"  \nFall 2020 15-121 (Reid-Miller) 12  \nWhat does the following Java statement do to this linked list?  \nlist [list.next](list.next) [list.next.next](list.next.next)  \nlist  \"C\"    \n[3.](3. list.next.next.next = list)[ list.next.next.next = list](3. list.next.next.next = list);  \nlist  \"A\"  \nA circular linked list!  \nFall 2020 15-121 (Reid-Miller) 13","cbCaieiNPEX2zizI","https://ap.wps.com/l/cbCaieiNPEX2zizI","pdf",783998,48,"English","# Exam 1 during class Thursday\n## Course topics and review sessions\n## Homework and today’s implementation focus\n# HW5 card game: dealing cards efficiently\n## Two ways to deal from a pile\n## Code/efficiency guidance\n# Linked lists vs arrays\n## Advantages\n## Disadvantages\n# Singly-linked list visualization\n## head reference and null termination\n## Creating an empty linked list\n# Java statements on next references\n## Example 1: list = list.next\n## Example 2: list.next = list.next.next\n## Example 3: list.next.next.next = list","[{\"question\":\"What are the main advantages and disadvantages of linked lists compared to arrays/ArrayLists?\",\"answer\":\"Linked lists avoid needing large contiguous memory, break arrays into smaller pieces, and can grow or shrink without copying data. They also have sequential access, making middle access slower, so arrays/ArrayLists do better at random access.\"},{\"question\":\"How do you represent an empty singly-linked list in this class?\",\"answer\":\"An empty linked list has the head reference equal to null (e.g., Node list = null). This differs from empty Strings or ArrayLists, where you can still query length or size and potentially add elements.\"},{\"question\":\"Which is more efficient for dealing a card from a pile: pile.remove(0) or pile.remove(pile.size()-1), and why?\",\"answer\":\"pile.remove(0) is O(n), while pile.remove(pile.size()-1) is O(1). The latter is easier to code and more efficient according to the notes.\"}]","Singly-Linked List Class - Exam 1 - Review and HW5 Card Game Efficiency | PDF",121,[146,150,154,158,162],{"page_no":22,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/466c8cfbc15112cb6bc6698b906d6016.webp",983,737,{"page_no":26,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/2d58a7fe70376c5c0c52262f0fc45fdc.webp",982,736,{"page_no":30,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/cc4fd94b05dba6c38b030dcc391e5a88.webp",981,735,{"page_no":33,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/06c60551a318460101b14564dd9b9e69.webp",980,734,{"page_no":96,"url":163,"width":164,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/48e1d82b80545c295656378ff011573c.webp",979,{"list":166,"token":11},[167,173,179,185,191,197,203,210,216,222],{"doc_id":168,"doc_title":169,"file_type":137,"home_preview_img_url":170,"slug":171,"view_count":123,"category_name":29,"create_tm":172},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=1796205359&Signature=iJKypQ19wkffoHl8e5bpyLRxJ9o%3D","chapter-14-linked-lists-chapter-14-operations-and-implementations-of-singly-linked-lists",1794017196,{"doc_id":174,"doc_title":175,"file_type":137,"home_preview_img_url":176,"slug":177,"view_count":123,"category_name":29,"create_tm":178},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=1796205359&Signature=oc2amKxvwnxLKoP31qmfnvcD3j4%3D","cs-2351-data-structures-linked-lists",1794017950,{"doc_id":180,"doc_title":181,"file_type":137,"home_preview_img_url":182,"slug":183,"view_count":101,"category_name":29,"create_tm":184},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=1796205359&Signature=XP6gprJfB6kVE0z3MSm5ODuxFRc%3D","linked-list-lecture-23-24-notes",1794446335,{"doc_id":186,"doc_title":187,"file_type":137,"home_preview_img_url":188,"slug":189,"view_count":30,"category_name":29,"create_tm":190},697964,"UNIT III - PART-A - Linear Data Structures and ADTs: List, Stack, and Queue","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010143042/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796205359&Signature=fNRglLpPmqSTKjRA1Cck9Mp4I%2FE%3D","unit-iii-part-a-linear-data-structures-and-adts-list-stack-and-queue",1794446383,{"doc_id":192,"doc_title":193,"file_type":137,"home_preview_img_url":194,"slug":195,"view_count":115,"category_name":29,"create_tm":196},670584,"Java Data Structures Cheat Sheet","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988344079/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796205359&Signature=ca%2BUaxpD3uMfg%2BWWnysUgcA6RtQ%3D","java-data-structures-cheat-sheet",1793570142,{"doc_id":198,"doc_title":199,"file_type":137,"home_preview_img_url":200,"slug":201,"view_count":115,"category_name":29,"create_tm":202},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=1796205359&Signature=L2xryN45UhHVFfi41WJz6ZNa3FI%3D","c-linked-lists-review-list-operations-and-traversal",1794016536,{"doc_id":204,"doc_title":205,"file_type":137,"home_preview_img_url":206,"slug":207,"view_count":208,"category_name":29,"create_tm":209},314665,"AP® Computer Science A - Sample Syllabus #1 - Course Framework Topics","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229907672957/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796205359&Signature=wju6gwADH4iEoYbZYOI1On1rL9A%3D","ap-computer-science-a-sample-syllabus-1-course-framework-topics",13,1789901400,{"doc_id":211,"doc_title":212,"file_type":137,"home_preview_img_url":213,"slug":214,"view_count":30,"category_name":29,"create_tm":215},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=1796205359&Signature=TrXk7CyG%2F2XuwNLXwbwasDAH37s%3D","linked-lists-in-mips-mips-implementation-recursive-functions-isa-and-x86-vs-mips-comparison",1795382683,{"doc_id":217,"doc_title":218,"file_type":137,"home_preview_img_url":219,"slug":220,"view_count":33,"category_name":29,"create_tm":221},697947,"Linked List in Python - Lecture 4 - Implementation","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010140976/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796205359&Signature=26Pc%2BZCdRK%2Fz12cyA8pNYkXKzH8%3D","linked-list-in-python-lecture-4-implementation",1794446273,{"doc_id":223,"doc_title":224,"file_type":137,"home_preview_img_url":225,"slug":226,"view_count":227,"category_name":29,"create_tm":228},391235,"C Language Questions and Answers - Study & Interview Quick Reference","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917369724/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796205359&Signature=6FnTo6GqW%2FObEmMo3YB%2F2Xl%2FgF4%3D","c-language-questions-and-answers-study-interview-quick-reference",17,1790350259]