[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-685666-105":3,"detail-sidebar-cat-0-en-105":81,"doc-detail-685666-en":130,"doc-similar-685666":164},{"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","lecture-6-list-adt","Lecture 6 - List ADT","","Lecture 6 explains the List ADT and why it is pervasive in computing. It covers the specification of ListBase in C++, including core operations isEmpty, getLength, insert, remove, retrieve, and toString, plus key design decisions. The lecture contrasts two implementations: array-based and linked-list-based, then details the array version’s insertion and deletion logic, including best and worst cases, shifting elements, closing gaps, and updating the list size.",{"@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/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/lecture-6-list-adt/685666/",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/lecture-6-list-adt/685666.png","ImageObject",300,407,{"name":42,"@type":43},"Muffet","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",6,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What is the List ADT and why is it important in computing?","Question",{"text":63,"@type":64},"The List ADT is a sequence of items where positional order matters. Lists are pervasive in computing, such as student lists, event lists, and appointment lists.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"What operations are included in the C++ ListBase specification?",{"text":68,"@type":64},"ListBase defines isEmpty, getLength, insert(index,newItem), remove(index), retrieve(index,dataItem), and toString for printing and debugging.",{"name":70,"@type":61,"acceptedAnswer":71},"How does array-based insertion work in the array implementation?",{"text":72,"@type":64},"Insertion can be simplest when adding at the end. Other insertions require shifting items to create a gap, and the worst case occurs when inserting at the head; then size is updated.","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},685666,1794016534,{"code":4,"msg":82,"data":83},"success",[84,88,92,96,101,104,109,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":93,"show_sort_weight":94,"slug":95},"Exam",70,"exam",{"id":97,"doc_module":4,"doc_module_name":25,"category_name":98,"show_sort_weight":99,"slug":100},5,"Comic",60,"comic",{"id":55,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},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":97,"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":55,"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":102,"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":80,"read_time":143,"preview_page_count":97,"preview_urls":144},962090768927,"https://ap-avatar.wpscdn.com/davatar_085a072bc5b1113ac321206ff7593b45","Lecture 6  \nList ADT  \nIt is very pervasive  \nLecture Overview  \n􀂄 List ADT  \n􀂉 Specification  \n􀂄 Implementation for List ADT  \n􀂉 Array Based  \n􀂄 Pros and Cons  \n􀂉 Linked List Based  \n􀂄 Pros and Cons  \nList ADT  \n􀂄 A sequence of items where positional order matter \u003Ca 1 , a 2 ,…, an-1 , an >  \n􀂄 Lists are very pervasive in computing  \n􀂉 e.g. student list, list of events, list of appointments etc  \nisEmpty()  \nList  \nretrieve(idx, item)  \nList()  \nadd(idx, item)  \nremove(idx) getLength()  \nidx : Position, integer  \nitem : Data stored in list, can be any data type  \nThe listADT  \n List ADT : C++ Specification   \n// includes are not shown  \nclass ListBase {  \npublic:  \nvirtual bool isEmpty() = 0; Operations to check on the state of list.   \nvirtual int getLength() = 0;  \n The three major operations   \nvirtual bool insert (int index, const int& newItem) = 0;  \nvirtual bool remove (int index) = 0;  \nvirtual bool retrieve (int index, int& dataItem) = 0;  \nvirtual string toString() = 0;  Operation to ease printing & debugging. };  \nListBase .h  \nDesign Decisions   \n􀂄 This is a simplified design:  \n􀂉 to reduce the \"syntax burden\"  \n􀂉 to concentrate on the internal logic  \n􀂄 You are encouraged to enhance the class:  \n􀂉 After you have understood the internal logic  \n􀂄 Possible enhancements:  \n􀂉 Use Template Class:  \n􀂄 So that list can contain item of any data type  \n􀂉 Use Inheritance + Polymorphism:  \n􀂄 Similar to the Complex Number ADT  \nTwo Major Implementations  \n1. Array implementation  \n2. Linked list implementation (discussed soon)  \n􀂄 General steps:  \n1. Choose an internal data structure  \n􀂄 e.g. Array or linked list  \n2. Figure out the algorithm needed for each of the major operations in List ADT:  \n􀂄 insert, remove, and retrieve  \n3. Implement the algorithm from step (2)  \nList ADT – Version A  \nArray Implementation  \n Implement List ADT: Using Array   \n􀂄 Array is a prime candidate for implementing the ADT  \n􀂉 Simple construct to handle a collection of items  \n􀂄 Advantage:  \n􀂉 Very fast retrieval  \n| size\u003Cbr>\u003Cbr>n  | array with [0.. m] of locations \u003Cbr>a 1 a 2 a 3 ………………… an ………\u003Cbr>0 1 2   n-1 m-1 |\n| --- | --- |\n\nInternal of the list ADT, Array Version  \n Insertion : Using Array   \n􀂄 Simplest Case: Insert to the end of array  \n􀂄 Other Insertions:  \n􀂉 Some items in the list needs to be shifted  \n􀂉 Worst case: Inserting at the head of array  \nExample : Insert item “it” into the 3 rd position  \nsize  items  \nsize  \nStep 1 : Shift right  \nStep 2 : Write into gap  \n9   \n\n| a 1 | a 2 | it\u003Cbr>| a 3 | a 4  | a 5 | a 6 | a 7 | a 8 | ……… |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n\nStep 3 : Update Size  \nDeletion: Using Array  \n􀂄 Simplest Case: Delete item from the end of array  \n􀂄 Other deletions:  \n􀂉 Items needs to be shifted  \n􀂉 Worst Case: Deleting at the head of array  \nExample:  \nsize  \n8   \nsize  \n7   \nremove the item at 5th position  \n| a 1 | a 2 | a 3 | a 4 | a 5  | a 6 | a 7 | a 8 | |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- |\n\n………  \nStep 1 : Close Gap  \n\n| a 1 | a 2 | a 3 | a 4 | a 6  | a 7 | a 8 | | | ……… |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n\nStep 2 : Update Size","cbCaitcOapPQsWmW","https://ap.wps.com/l/cbCaitcOapPQsWmW","pdf",1938294,"English","# List ADT\n## Lecture Overview\n## List ADT Specification\n## Design Decisions\n## Two Major Implementations\n## Array Implementation\n## Insertion Using Array\n## Deletion Using Array","[{\"question\":\"What is the List ADT and why is it important in computing?\",\"answer\":\"The List ADT is a sequence of items where positional order matters. Lists are pervasive in computing, such as student lists, event lists, and appointment lists.\"},{\"question\":\"What operations are included in the C++ ListBase specification?\",\"answer\":\"ListBase defines isEmpty, getLength, insert(index,newItem), remove(index), retrieve(index,dataItem), and toString for printing and debugging.\"},{\"question\":\"How does array-based insertion work in the array implementation?\",\"answer\":\"Insertion can be simplest when adding at the end. Other insertions require shifting items to create a gap, and the worst case occurs when inserting at the head; then size is updated.\"}]","Lecture 6 - List ADT | PDF",126,[145,149,153,157,160],{"page_no":22,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/5ae5a92abea1d7e13bffdf3fb0e85d60.webp",983,759,{"page_no":26,"url":150,"width":151,"height":152},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/17eb82e3cf42099be526c6e2078a3fc2.webp",982,758,{"page_no":30,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/838fd22c334b4be68968cb97c45ee701.webp",981,757,{"page_no":33,"url":158,"width":159,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/a3bfca894c10f9c7a1e3245c1501e957.webp",980,{"page_no":97,"url":161,"width":162,"height":163},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/74e765b7f14ff88b95147ed4e936d855.webp",979,756,{"list":165,"token":11},[166,172,178,184,190,196,202,208,214,220],{"doc_id":167,"doc_title":168,"file_type":137,"home_preview_img_url":169,"slug":170,"view_count":33,"category_name":29,"create_tm":171},719603,"CS1020 Data Structures and Algorithms I Lecture 10 - List ADT & Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230023815866/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=Wk4jvHmweD3QvFt1OdIgeQ5jqnc%3D","cs1020-data-structures-and-algorithms-i-lecture-10-list-adt-linked-lists",1795006746,{"doc_id":173,"doc_title":174,"file_type":137,"home_preview_img_url":175,"slug":176,"view_count":55,"category_name":29,"create_tm":177},685764,"Lists and Linked Lists - Part 1 - Introduction","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999691137/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=rafDpagRIpQFLYYMywo29Ge7NQc%3D","lists-and-linked-lists-part-1-introduction",1794017635,{"doc_id":179,"doc_title":180,"file_type":137,"home_preview_img_url":181,"slug":182,"view_count":33,"category_name":29,"create_tm":183},685792,"Array Implementation of List - Array Operations (Create, Insert, Delete, Display, Search)","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000212417/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=fvbOvEd3CKodo6%2BqoFICC0B0Cjk%3D","array-implementation-of-list-array-operations-create-insert-delete-display-search",1794018669,{"doc_id":185,"doc_title":186,"file_type":137,"home_preview_img_url":187,"slug":188,"view_count":97,"category_name":29,"create_tm":189},670913,"STACKS, QUEUES, AND LINKED LISTS - Stacks","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988353256/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=SRcZ7NR84KaEMNLvT9Yf0Xna3sY%3D","stacks-queues-and-linked-lists-stacks",1793572679,{"doc_id":191,"doc_title":192,"file_type":137,"home_preview_img_url":193,"slug":194,"view_count":55,"category_name":29,"create_tm":195},685634,"Python Collections - Arrays - List and Function","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999084045/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=sgpgDAh6VCeH33ajmgkHEI7k%2BhI%3D","python-collections-arrays-list-and-function",1794016101,{"doc_id":197,"doc_title":198,"file_type":137,"home_preview_img_url":199,"slug":200,"view_count":97,"category_name":29,"create_tm":201},685686,"ArrayList in Java","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179246/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=mJ2G9rbU3%2ByqX73ioF4GXgE8MaY%3D","arraylist-in-java",1794016760,{"doc_id":203,"doc_title":204,"file_type":137,"home_preview_img_url":205,"slug":206,"view_count":55,"category_name":29,"create_tm":207},697937,"Doubly Linked List - Basic Operations and Circular Linked List","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010136388/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=r2LzyERABNls0OmzCYH0mATAWmA%3D","doubly-linked-list-basic-operations-and-circular-linked-list",1794446062,{"doc_id":209,"doc_title":210,"file_type":137,"home_preview_img_url":211,"slug":212,"view_count":33,"category_name":29,"create_tm":213},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=1796111219&Signature=DLP6SM%2FGDlOiSb2hKlMLBrieYMc%3D","lecture-17-linked-list-data-structure-part-ii-double-linked-list-applications-and-insertion",1795006749,{"doc_id":215,"doc_title":216,"file_type":137,"home_preview_img_url":217,"slug":218,"view_count":33,"category_name":29,"create_tm":219},732878,"Linked Lists - Overview - Advantages and Operations","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031780342/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=mQlSI84A6y71izzk7lOwufxagrU%3D","linked-lists-overview-advantages-and-operations",1795382677,{"doc_id":221,"doc_title":222,"file_type":137,"home_preview_img_url":223,"slug":224,"view_count":33,"category_name":29,"create_tm":225},697946,"Sequence Interface - Sequence Interface（L02, L07）","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010141005/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111219&Signature=dcvgd1oN6kQK%2BjLrLjuFfi%2FlgrM%3D","sequence-interface-sequence-interfacel02-l07",1794446272]