[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-697946-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-697946-en":130,"doc-similar-697946":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","sequence-interface-sequence-interfacel02-l07","Sequence Interface - Sequence Interface（L02, L07）","","Recitation 2 covers the Sequence and Set interfaces from MIT 6.006, explaining how sequences store items in an extrinsic rank order while sets rely on intrinsic properties such as keys x.key. The material compares static and dynamic container operations, including build, iteration, indexed access, insertion/deletion at positions, and order queries like min/max/next/prev. It then introduces sequence implementations, discussing array-backed sequences, memory allocation, and the time trade-offs of random access versus costly insertions and deletions.",{"@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/sequence-interface-sequence-interfacel02-l07/697946/",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/sequence-interface-sequence-interfacel02-l07/697946.png","ImageObject",300,407,{"name":42,"@type":43},"miraaa_2004","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-17","2026-11-12",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What does it mean that a sequence has an extrinsic order?","Question",{"text":62,"@type":63},"The first and last items are determined by an external ranking rather than by intrinsic properties of the items themselves.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"How are sets defined differently from sequences?",{"text":67,"@type":63},"Sets organize items by an intrinsic property, typically a unique key x.key, and support queries based on that key.",{"name":69,"@type":60,"acceptedAnswer":70},"Why can array-based sequences have O(1) get/set but slower insert/delete?",{"text":71,"@type":63},"Array indexing enables constant-time random access, but insertion or deletion requires shifting elements and resizing, which can take linear time in the worst case.","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},697946,1794446272,{"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":33,"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},962094249165,"https://ap-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","Introduction to Algorithms: 6.006 Massachusetts Institute of Technology  \nInstructors: Erik Demaine, Jason Ku, and Justin Solomon Recitation 2  \nRecitation 2  \nSequence Interface (L02, L07)  \nSequences maintain a collection of items in an extrinsic order, where each item stored has a rankin the sequence, including a ﬁrst item and a last item. By extrinsic, we mean that the ﬁrst item is‘ﬁrst’, not because of what the item is, but because some external party put it there. Sequences are generalizations of stacks and queues, which support a subset of sequence operations.  \n\n| Container | build(X) len() | given an iterable X, build sequence from items in X return the number of stored items |\n| --- | --- | --- |\n| Static | iter   seq() | return the stored items one-by-one in sequence order |\n|  | get at(i) | return the ith item |\n|  | set  at(i, x) | replace the ith item with x |\n| Dynamic | insert at(i, x) | add x as the ith item |\n|  | delete   at(i) | remove and return the ith item |\n|  | insert first(x) | add x as the ﬁrst item |\n|  | delete   first() | remove and return the ﬁrst item |\n|  | insert last(x) | add x as the last item |\n|  | delete   last() | remove and return the last item |\n\n(Note that insert  / delete   operations change the rank of all items after the modiﬁed item.)  \nSet Interface (L03-L08)  \nBy contrast, Sets maintain a collection of items based on an intrinsic property involving what the items are, usually based on a unique key, x.key, associated with each item x. Sets are generalizations of dictionaries and other intrinsic query databases.  \n\n| Container | build(X) len() | given an iterable X, build set from items in X\u003Cbr>return the number of stored items |\n| --- | --- | --- |\n| Static | find(k) | return the stored item with key k |\n| Dynamic | insert(x)\u003Cbr>delete(k) | add x to set (replace item with key x.key if one already exists) remove and return the stored item with key k |\n| Order | iter   ord()\u003Cbr>find min()\u003Cbr>find max()\u003Cbr>find   next(k)\u003Cbr>find prev(k) | return the stored items one-by-one in key order return the stored item with smallest key\u003Cbr>return the stored item with largest key\u003Cbr>return the stored item with smallest key larger than k\u003Cbr>return the stored item with largest key smaller than k |\n\n(Note that find operations return None if no qualifying item exists.)  \nSequence Implementations  \nHere, we will discuss three data structures to implement the sequence interface. In Problem Set 1, you will extend both Linked Lists and Dynamic arrays to make both ﬁrst and last dynamic operations O(1) time for each. Notice that none of these data structures support dynamic operations at arbitrary index in sub-linear time. We will learn how to improve this operation in Lecture 7.  \nArray Sequence  \nComputer memory is a ﬁnite resource. On modern computers many processes may share the same main memory store, so an operating system will assign a ﬁxed chunk of memory addresses to each active process. The amount of memory assigned depends on the needs of the process and the availability of free memory. For example, when a computer program makes a request to store a variable, the program must tell the operating system how much memory (i.e. how many bits) will be required to store it. To fulﬁll the request, the operating system will ﬁnd the available memory in the process’s assigned memory address space and reserve it (i.e. allocate it) for that purpose until it is no longer needed. Memory management and allocation is a detail that is abstracted away by many high level languages including Python, but know that whenever you ask Python to store something, Python makes a request to the operating system behind-the-scenes, for a ﬁxed amount of memory in which to store it.  \nNow suppose a computer program wants to store two arrays, each storing ten 64-bit words. The program makes separate requests for two chunks of memory (640 bits each), and the operating system fulﬁlls the request by, for example, reserving the ﬁrs","cbCaimX1lU6XbjX7","https://ap.wps.com/l/cbCaimX1lU6XbjX7","pdf",257188,"English","# Sequence Interface\n## Sequence vs Set Interfaces\n# Static and Dynamic Container Operations\n## Sequence Operations\n## Set Operations and Key Ordering\n# Sequence Implementations\n## Array Sequence and Memory Model","[{\"question\":\"What does it mean that a sequence has an extrinsic order?\",\"answer\":\"The first and last items are determined by an external ranking rather than by intrinsic properties of the items themselves.\"},{\"question\":\"How are sets defined differently from sequences?\",\"answer\":\"Sets organize items by an intrinsic property, typically a unique key x.key, and support queries based on that key.\"},{\"question\":\"Why can array-based sequences have O(1) get/set but slower insert/delete?\",\"answer\":\"Array indexing enables constant-time random access, but insertion or deletion requires shifting elements and resizing, which can take linear time in the worst case.\"}]","Sequence Interface - Sequence Interface（L02, L07） | 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-12/f3b22cb934484802f9915c163fabbc58.webp",983,1272,{"page_no":26,"url":150,"width":151,"height":152},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/c2b68bf6fdc05beb7591c0a4a2a693ba.webp",982,1270,{"page_no":30,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/df3ffd8256036a8e97de6c84235dab64.webp",981,1269,{"page_no":33,"url":158,"width":159,"height":160},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/4b0a0945c91af5a9a636109e5f584dd7.webp",980,1268,{"list":162,"token":11},[163,169,175,181,187,193,199,206,212,218],{"doc_id":164,"doc_title":165,"file_type":137,"home_preview_img_url":166,"slug":167,"view_count":96,"category_name":29,"create_tm":168},685721,"Sequences - Representing Sequences by Arrays and Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999688553/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=0mwPRsYfctMflx6JNOw3vtIzl3o%3D","sequences-representing-sequences-by-arrays-and-linked-lists",1794016978,{"doc_id":170,"doc_title":171,"file_type":137,"home_preview_img_url":172,"slug":173,"view_count":96,"category_name":29,"create_tm":174},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=1796111639&Signature=x4C3gcfgDeOmMfB73zke%2F0Rm0VQ%3D","linked-lists-introduction-properties-advantages-disadvantages-and-types",1794016969,{"doc_id":176,"doc_title":177,"file_type":137,"home_preview_img_url":178,"slug":179,"view_count":101,"category_name":29,"create_tm":180},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=1796111639&Signature=zt0CMNAY1YycTZjDl4CRP%2FSB4SQ%3D","lists-and-linked-lists-part-1-introduction",1794017635,{"doc_id":182,"doc_title":183,"file_type":137,"home_preview_img_url":184,"slug":185,"view_count":105,"category_name":29,"create_tm":186},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=1796111639&Signature=qlB%2FjzI1Oq6b8ne2o9N9MMECwJE%3D","high-performance-lists-in-java-javazone-2015-motivation-a-real-world-example",1794016775,{"doc_id":188,"doc_title":189,"file_type":137,"home_preview_img_url":190,"slug":191,"view_count":101,"category_name":29,"create_tm":192},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=1796111639&Signature=zP9pZOmp%2F3w0QEzd3XX4t9gxzLw%3D","linked-lists-fundamentals-core-concepts-and-c-implementation-notes",1794017949,{"doc_id":194,"doc_title":195,"file_type":137,"home_preview_img_url":196,"slug":197,"view_count":96,"category_name":29,"create_tm":198},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=1796111639&Signature=lzbFWeeykchjwkt5w9YEUOY%2FdjA%3D","chapter-4-linked-lists-41-singly-linked-lists-or-chains",1794017203,{"doc_id":200,"doc_title":201,"file_type":137,"home_preview_img_url":202,"slug":203,"view_count":204,"category_name":29,"create_tm":205},655561,"UML Sequence Diagrams - Engineering Notebook Column - April, 98","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975285299/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=SPXCOJhG6a583GPAmASRL7NSg%2Bo%3D","uml-sequence-diagrams-engineering-notebook-column-april-98",12,1792962636,{"doc_id":207,"doc_title":208,"file_type":137,"home_preview_img_url":209,"slug":210,"view_count":105,"category_name":29,"create_tm":211},685773,"Lists and Tuples - Chapter 7 - Programming Concepts","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203784/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=RSeMRqxz7AsLGPFyZqSaivnOFlE%3D","lists-and-tuples-chapter-7-programming-concepts",1794018219,{"doc_id":213,"doc_title":214,"file_type":137,"home_preview_img_url":215,"slug":216,"view_count":96,"category_name":29,"create_tm":217},655605,"Mealy and Moore State Diagrams - Sequence Detector Design","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975286063/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=PvsLjeKYbIBJeEAfvOBWCqRi8YE%3D","mealy-and-moore-state-diagrams-sequence-detector-design",1792962854,{"doc_id":219,"doc_title":220,"file_type":137,"home_preview_img_url":221,"slug":222,"view_count":96,"category_name":29,"create_tm":223},671624,"Python Cheat Sheet - Complex Data Types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988737384/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=ZcNn5fiUUHrTLacxxg1aC4jkKlk%3D","python-cheat-sheet-complex-data-types",1793577649]