[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-573430-105":3,"detail-sidebar-cat-1-en-105":79,"doc-detail-573430-en":125},{"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":72,"head_meta":74,"extra_data":76,"updated_unix":78},105,"en","cs-161-section-w1-asymptotic-analysis-proof-by-induction-spring-2023","CS 161 Section - W1: Asymptotic Analysis, Proof by Induction - Spring 2023","","Lecture section notes for CS 161 covering W1 topics: asymptotic analysis and proof by induction, with emphasis on how to reason about algorithm performance. Includes pseudocode guidance for designing a clear step-by-step procedure (e.g., matching a socket to a light bulb) and examples illustrating acceptable versus lecture-derived algorithm descriptions. Provides Big-O notation definitions using English, picture/intuitive runtime growth concepts, and formal mathematical conditions, plus structured advice for formally proving Big-O bounds by choosing constants c and n0.",{"@graph":14,"@context":71},[15,34,54],{"@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/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/presentations/","Presentations",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/cs-161-section-w1-asymptotic-analysis-proof-by-induction-spring-2023/573430/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":48,"encodingFormat":47,"isAccessibleForFree":49,"interactionStatistic":50},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/cs-161-section-w1-asymptotic-analysis-proof-by-induction-spring-2023/573430.png","ImageObject",442,249,{"name":42,"@type":43},"Kurz","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-14",true,{"@type":51,"interactionType":52,"userInteractionCount":22},"InteractionCounter",{"@type":53},"ViewAction",{"@type":55,"mainEntity":56},"FAQPage",[57,63,67],{"name":58,"@type":59,"acceptedAnswer":60},"What does it mean to say T(n) is O(f(n))?","Question",{"text":61,"@type":62},"T(n) = O(f(n)) means T(n) is eventually bounded above by a constant multiple of f(n). The formal statement uses the existence of positive constants c and n0 such that for all n ≥ n0, T(n) ≤ c · f(n).","Answer",{"name":64,"@type":59,"acceptedAnswer":65},"How should pseudocode be written in this section?",{"text":66,"@type":62},"Pseudocode should provide a clear description of the steps. The notes contrast an explicit step description with variants that reuse lecture algorithms (e.g., binary search) while simplifying pseudocode as much as possible and maintaining readable logic.",{"name":68,"@type":59,"acceptedAnswer":69},"How do you formally prove that T(n) is O(f(n))?",{"text":70,"@type":62},"Use the mathematical definition: announce c and n0 up front, then show that T(n) ≤ c · f(n) for all n ≥ n0. The proof must ensure those chosen values are positive constants.","https://schema.org",{"og:url":32,"og:type":73,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":75,"canonical":32},"index,follow",{"doc_id":77,"site_id":7},573430,1792016110,{"code":4,"msg":80,"data":81},"success",[82,86,91,96,101,106,111,116,121],{"id":83,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":84,"slug":85},11,90,"presentations",{"id":87,"doc_module":22,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},12,"Resumes",80,"resumes",{"id":92,"doc_module":22,"doc_module_name":25,"category_name":93,"show_sort_weight":94,"slug":95},14,"Invoices",70,"invoices",{"id":97,"doc_module":22,"doc_module_name":25,"category_name":98,"show_sort_weight":99,"slug":100},15,"Posters",60,"posters",{"id":102,"doc_module":22,"doc_module_name":25,"category_name":103,"show_sort_weight":104,"slug":105},16,"Social Media",50,"social-media",{"id":107,"doc_module":22,"doc_module_name":25,"category_name":108,"show_sort_weight":109,"slug":110},17,"Forms",40,"forms",{"id":112,"doc_module":22,"doc_module_name":25,"category_name":113,"show_sort_weight":114,"slug":115},18,"Letters",30,"letters",{"id":117,"doc_module":22,"doc_module_name":25,"category_name":118,"show_sort_weight":119,"slug":120},21,"Paper Templates",5,"papers-templates",{"id":122,"doc_module":22,"doc_module_name":25,"category_name":123,"show_sort_weight":4,"slug":124},158,"General","general-158",{"code":4,"msg":80,"data":126},{"doc_id":77,"user_id":127,"nickname":42,"user_avatar":128,"doc_module":22,"category_id":83,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":129,"file_id":130,"file_url":131,"file_type":132,"file_size":133,"view_count":22,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":134,"language":135,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":12,"update_tm":139,"read_time":140},2336478945635,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","CS 161 Section  \nW1: Asymptotic analysis, proof by induction.  \nSpring 2023  \nModiﬁed by Sophia Sanchez from Avery Wang’s Winter 2021 ACE Section  \nPSEUDOCODE  \nWhat is good pseudocode?  \n2  \nPSEUDOCODE  \nClear description of the steps  \nSetup: You have light bulbs of different sizes placed in order of their size, and have 1 socket. How do you match the sock to the light bulb?  \n\n| find_matching_light_bulb (LightBulbs, Socket)\u003Cbr>search the light bulbs and return the matching lightbulb with the socket | find_matching_light_bulb (lightBulbs, socket)\u003Cbr>for lightBulb in lightBulbs:\u003Cbr>if lightBulb and socket match: return lightBulb\u003Cbr>return no matching light bulb found |\n| --- | --- |\n\nPSEUDOCODE  \n Use algorithms covered in lectures without their pseudocode  \n\n| find_matching_light_bulb (LightBulbs, Socket)\u003Cbr>run binary_search to find the matching light bulb. | find_matching_light_bulb (lightBulbs, socket)\u003Cbr>ind= modified_binary_search(lightBulbs,\u003Cbr>socket)\u003Cbr>if lightBulbs[ind] matches with socket:\u003Cbr>return lightBulbs[ind] else:\u003Cbr>return no matching light bulb found\u003Cbr>❖ modified_binary_search is binary_search, but we change it [in this specific way]. |\n| --- | --- |\n\nPSEUDOCODE  \n Simplify pseudocode as much as possible  \n\n| find_matching_light_bulb (lightBulbs, socket) if the 1st light bulb matches the socket:\u003Cbr>return the first light bulb\u003Cbr>if the 2nd light bulb matches the socket: return the 2nd light bulb\u003Cbr>if the 3rd light bulb matches the socket: return the 3rd light bulb\u003Cbr>…\u003Cbr>if the nth light bulb matches the socket:\u003Cbr>return the nth light bulb return no matching light bulb found | find_matching_light_bulb (lightBulbs, socket)\u003Cbr>for lightBulb in lightBulbs:\u003Cbr>if lightBulb and socket match: return lightBulb\u003Cbr>return no matching light bulb found |\n| --- | --- |\n\nPSEUDOCODE  \n Clear description of the steps  \n Use algorithms covered in lectures without their pseudocode  Simplify pseudocode as much as possible  \nBIG-O NOTATION  \n7  \nBIG-O NOTATION  \nLet T(n) & f(n) be functions deﬁned on the positive integers.  \n(In this class, we’ll typically write T(n) to denote the worst case runtime of an algorithm)  \nWhat do we mean when we say “T(n) is O(f(n))”?  \nIn English  \nT(n) = O(f(n)) if and only if T(n) is eventually upper bounded by a constant multiple of f(n)  \nIn Pictures  \nRunt ime (ms)  \nn 0  \nn (input size)  \nc ·f(n)  \nT(n)  \nf(n)  \nIn Math  \nT(n) = O(f(n)) if and only if there exists positive constantsc and n0 such that for all n ≥ n0 T(n) ≤ c · f(n)  \n8  \nBIG-O NOTATION  \nLet T(n) & f(n) be functions deﬁned on the positive integers.  \n(In this class, we’ll typically write T(n) to denote the worst case runtime of an algorithm)  \nWhat do we mean when we say “T(n) is O(f(n))”?  \nIn English  \nT(n) = O(f(n)) if and only if T(n) is eventually upper bounded by a constant multiple of f(n)  \nIn Pictures  \nRunt ime (ms)  \nn 0  \nn (input size)  \nc ·f(n)  \nT(n)  \nf(n)  \nIn Math  \nT(n) = O(f(n))  \n“for all”  \n“if and only if”  ⇔ ∃ c , n0 > 0 s.t. ∀ n ≥ n0 ,  T(n) ≤ c · f(n) “such that”  \n“there exists”  \n9  \nPROVING BIG-O BOUNDS  \nIf you’re ever asked to formally prove that T(n) is O(f(n)), use the MATH deﬁnition:  \nT(n) = O(f(n))  \n⇔  \n∃ c , n0 > 0 s.t. ∀ n ≥ n0 ,  \nmust be constants!  \nT(n) ≤ c · f(n) i. . ce&penn0dcannon n!ot  \n● To prove T(n) = O(f(n)), you need to announce your c & n0 up front!   \n○ Play around with the expressions to ﬁnd appropriate choices of c & n0 (positive constants)  \n○ Then you can write the proof! Here how to structure the start of the proof:  \n“Let c =   and n0 =   . We will show that T(n) ≤ c ・f(n) for all n ≥ n0 .”","cbCaim06qKdQMcdj","https://ap.wps.com/l/cbCaim06qKdQMcdj","pdf",432356,38,"English","# W1: Asymptotic analysis, proof by induction\n## Pseudocode guidelines and examples\n## BIG-O notation\n## Proving BIG-O bounds","[{\"question\":\"What does it mean to say T(n) is O(f(n))?\",\"answer\":\"T(n) = O(f(n)) means T(n) is eventually bounded above by a constant multiple of f(n). The formal statement uses the existence of positive constants c and n0 such that for all n ≥ n0, T(n) ≤ c · f(n).\"},{\"question\":\"How should pseudocode be written in this section?\",\"answer\":\"Pseudocode should provide a clear description of the steps. The notes contrast an explicit step description with variants that reuse lecture algorithms (e.g., binary search) while simplifying pseudocode as much as possible and maintaining readable logic.\"},{\"question\":\"How do you formally prove that T(n) is O(f(n))?\",\"answer\":\"Use the mathematical definition: announce c and n0 up front, then show that T(n) ≤ c · f(n) for all n ≥ n0. The proof must ensure those chosen values are positive constants.\"}]","CS 161 Section - W1: Asymptotic Analysis, Proof by Induction - Spring 2023 | PDF",1791939579,13]