[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-697936-105":59,"doc-detail-697936-en":130,"doc-similar-697936":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","lecture-11-doubly-linked-lists","Lecture 11 - Doubly Linked Lists","","Lecture 11 covers doubly linked lists: each node stores references to the next and previous nodes plus an element object, illustrated with a generic DNode\u003C E > class. It explains how head and tail pointers support efficient operations such as removing the last element. The lecture highlights the challenge of edge cases (i = 0 and i = size - 1) in methods like removeLast(), including failures when only one node exists. It then motivates avoiding edge cases using “dummy nodes.”",{"@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/lecture-11-doubly-linked-lists/697936/",{"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/lecture-11-doubly-linked-lists/697936.png","ImageObject",300,407,{"name":92,"@type":93},"Malam Tenang","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-18","2026-11-12",true,{"@type":102,"interactionType":103,"userInteractionCount":19},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What does a node in a doubly linked list store?","Question",{"text":112,"@type":113},"Each node contains references to the next node and the previous node, plus an element object.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"Why is removing the last element fast in a doubly linked list?",{"text":117,"@type":113},"Because the list maintains a tail reference, removeLast() can update tail to tail.prev directly and then disconnect the old tail.",{"name":119,"@type":110,"acceptedAnswer":120},"What edge cases must be handled when accessing a node by index?",{"text":121,"@type":113},"Index 0 has a null prev field and index size - 1 has a null next field, so these cases require special attention to avoid errors.","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},697936,1794446060,{"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":19,"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},962093532863,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","COMP 250  \nLecture 11 doubly linked lists  \nJan. 31, 2022  \nLists  \n• array list  \n• singly linked list  \n• doubly linked list  \n:  \nDoubly linked list  \nEach node in the list has a reference to the next node and to the previous node, and to an element object.  \nnext  \nelement  \nprev  \nclass DNode\u003C E > {  \nnext  \nelement  \nprev  \nDNode\u003C E > next;  \nDnode\u003C E > prev;  \nE element;  \n// constructor  \nDNode( E e ) {  \nelement = e;  \nprev = null;  \nnext = null;}  \n}  \nDoubly linked list  \nnext prev element  \nnull  \nAs with a singly linked list, the doubly list list uses a head and tail reference .  \nhead  \ntail  \nnull  \n5  \nFor a doubly linked list, removing the last element is fast.  \nnext prev element  \nBEFORE  \nnull  \nremoveLast(){  \n}  \nhead  \ntail  \nnull  \nUnlike for a singly linked list, removing the last element of a doubly linked list is fast.  \nnext prev element  \nBEFORE  \nnull  \nremoveLast(){  \ntail = tail.prev [tail.next = null](tail.next = null)[ ](tail.next = null)[size = size](size = size) – 1  \n}  \nhead  \ntail  \ntail  \nUnlike for a singly linked list, removing the last element of a doubly linked list is fast.  \nBEFORE  \nnext prev element  \nnull  \nremoveLast(){  \ne = tail.element  \ntail = tail.prev [tail.next = null](tail.next = null)[ ](tail.next = null)[size = size](size = size) – 1  \nreturn e}  \nhead  \ntail  \ntail  \ne  \nSuppose we want to access node i in a doubly linked list.  \nOne issue is that edge cases (i = 0, i = size – 1) require special treatment: node 0 has a null prev field and node size-1 has a null next field.  \nWe would like to avoid testing special cases for each method, since this is error prone .  \nFor example, in the removeLast() method on the last slide, what if there was only one node? That code would not work. We forgot to adjust head!  \n[ADDED Feb. 10] Moreover, the instruction [tail. next = null](tail. next = null)[ ](tail. next = null)[would cause a null pointer exception](would cause a null pointer exception).]  \nAvoid edge cases with “dummy nodes”  \ndummyHead  \nThese indices are not part of the list.  \ni = 0  \ni = 1  \ni = 2  \ni = 3  \ndummyTail  \nnull  \nnull  \n10","cbCaifAtZbsAVP3E","https://ap.wps.com/l/cbCaifAtZbsAVP3E","pdf",1338468,36,"English","# Lecture 11 doubly linked lists\n## Doubly linked list structure\n## Head and tail references\n## Efficient removeLast() operation\n## Edge cases and correctness\n## Avoiding edge cases with dummy nodes","[{\"question\":\"What does a node in a doubly linked list store?\",\"answer\":\"Each node contains references to the next node and the previous node, plus an element object.\"},{\"question\":\"Why is removing the last element fast in a doubly linked list?\",\"answer\":\"Because the list maintains a tail reference, removeLast() can update tail to tail.prev directly and then disconnect the old tail.\"},{\"question\":\"What edge cases must be handled when accessing a node by index?\",\"answer\":\"Index 0 has a null prev field and index size - 1 has a null next field, so these cases require special attention to avoid errors.\"}]","Lecture 11 - Doubly Linked Lists | PDF",91,[146,150,154,158],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/9d85baf40d7efe1d0a2aa8aa01e5b03e.webp",983,759,{"page_no":14,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/60119c81e74d8b39365adb60ff8b9d2a.webp",982,758,{"page_no":81,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/e2d7cb6c27c583560c4a7902fc9ce5e5.webp",981,757,{"page_no":19,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/56897cbb68c9b04f923968d15baccd7d.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":24,"category_name":30,"create_tm":169},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=1796111279&Signature=0OP8tmzMFAi8xVBXDGMRpnNutLo%3D","l6b-linked-list-variations-lecture-6b",1794017196,{"doc_id":171,"doc_title":172,"file_type":137,"home_preview_img_url":173,"slug":174,"view_count":34,"category_name":30,"create_tm":175},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=1796111279&Signature=NUPXWk%2BsaCHf8rPmqb3FrsunesQ%3D","lecture-five-linked-list-structure",1794017204,{"doc_id":177,"doc_title":178,"file_type":137,"home_preview_img_url":179,"slug":180,"view_count":24,"category_name":30,"create_tm":181},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=1796111279&Signature=gv7RnjQA3vGAdwb%2FFWzq3dSTmcg%3D","linked-lists-introduction-properties-advantages-disadvantages-and-types",1794016969,{"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},685741,"ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY - Linked list implementation - Singly linked lists - Core algorithms for traversal, counting, searching and insertion","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000186201/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=232W9CUUJoULHftIdvfUEYJpohU%3D","rohini-college-of-engineering-technology-linked-list-implementation-singly-linked-lists-core-algorithms-for-traversal-counting-searching-and-insertion",1794017223,{"doc_id":189,"doc_title":190,"file_type":137,"home_preview_img_url":191,"slug":192,"view_count":34,"category_name":30,"create_tm":193},697943,"Lecture 12 Doubly Linked Lists - (with Recursion)","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230009212198/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=G82m7KvL8JgwnNGMHZQL0RtJDXg%3D","lecture-12-doubly-linked-lists-with-recursion",1794446071,{"doc_id":195,"doc_title":196,"file_type":137,"home_preview_img_url":197,"slug":198,"view_count":29,"category_name":30,"create_tm":199},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=1796111279&Signature=t2rU2WjCLbHWepkXR50wFy%2FUlek%3D","linked-lists-fundamentals-core-concepts-and-c-implementation-notes",1794017949,{"doc_id":201,"doc_title":202,"file_type":137,"home_preview_img_url":203,"slug":204,"view_count":19,"category_name":30,"create_tm":205},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=1796111279&Signature=8utzDubYEZAjMAT3xR0EsUwqIZY%3D","lecture-17-linked-list-data-structure-part-ii-double-linked-list-applications-and-insertion",1795006749,{"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},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=1796111279&Signature=CtCl7hS5WNgQj4wqtDD9XTlX32U%3D","cs62-class-8-linked-lists-basic-data-structures",1794017629,{"doc_id":213,"doc_title":214,"file_type":137,"home_preview_img_url":215,"slug":216,"view_count":24,"category_name":30,"create_tm":217},685667,"Implementing Singly Linked List in C++ - struct and pointers","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000175839/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=bpzP%2F99w8Mdn89587zil8pyLAGM%3D","implementing-singly-linked-list-in-c-struct-and-pointers",1794016535,{"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},685723,"Fundamentals of Linked Lists - Chapter Summary","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000182525/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=G85ZrJWZAblcoRpxs3gaa7erSxE%3D","fundamentals-of-linked-lists-chapter-summary",1794016982]