[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-573429-105":53,"doc-detail-573429-en":125},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":118,"head_meta":120,"extra_data":122,"updated_unix":124},105,"en","asymptotic-running-time-of-algorithms-formal-definition-of-big-o-notation-leading-term-analysis","Asymptotic Running Time of Algorithms - Formal Definition of big-O Notation - leading term analysis","","Asymptotic running time analysis explains how to classify algorithm efficiency using big-O notation. It formalizes the definition of f(n) being O(g(n)) via constants and a witness pair (c, n0), and shows examples including linear versus quadratic growth. The notes then guide leading-term comparison, log-base invariance, and how to count basic operations in the RAM model, while emphasizing that lower-order terms and irrelevant work can be ignored for asymptotic results.",{"@graph":63,"@context":117},[64,80,100],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/asymptotic-running-time-of-algorithms-formal-definition-of-big-o-notation-leading-term-analysis/573429/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":94,"encodingFormat":93,"isAccessibleForFree":95,"interactionStatistic":96},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/asymptotic-running-time-of-algorithms-formal-definition-of-big-o-notation-leading-term-analysis/573429.png","ImageObject",442,249,{"name":88,"@type":89},"Franzy","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-14",true,{"@type":97,"interactionType":98,"userInteractionCount":9},"InteractionCounter",{"@type":99},"ViewAction",{"@type":101,"mainEntity":102},"FAQPage",[103,109,113],{"name":104,"@type":105,"acceptedAnswer":106},"How do you prove that f(n) = O(g(n))?","Question",{"text":107,"@type":108},"Find constants c and n0 such that f(n) ≤ c·g(n) for all n > n0. The pair (c, n0) is called a witness pair.","Answer",{"name":110,"@type":105,"acceptedAnswer":111},"Why can lower-order terms, floors/ceilings, and constants be ignored?",{"text":112,"@type":108},"Asymptotic running time focuses on growth as n becomes large. Once the leading term dominates, those details do not change the big-O classification.",{"name":114,"@type":105,"acceptedAnswer":115},"What basic operations are commonly counted when analyzing searching and sorting?",{"text":116,"@type":108},"For searching and sorting algorithms, big-O is usually determined by counting worst-case comparisons. Typically, each comparison triggers a fixed number of primitive arithmetic/logical operations.","https://schema.org",{"og:url":78,"og:type":119,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":121,"canonical":78},"index,follow",{"doc_id":123,"site_id":56},573429,1792016547,{"code":4,"msg":5,"data":126},{"doc_id":123,"user_id":127,"nickname":88,"user_avatar":128,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":129,"file_id":130,"file_url":131,"file_type":132,"file_size":133,"view_count":9,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":134,"language":135,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":61,"update_tm":139,"read_time":76},2336478945519,"https://ap-avatar.wpscdn.com/davatar_085a072bc5b1113ac321206ff7593b45","Asymptotic Running Time of Algorithms  \nFormal Definition of big-O Notation:  \n• Let f(n) and g(n) be functions. We say f(n) is of order g(n), written O(g(n)), if there is a constant c > 0 such that for all but a finite number of positive values of n:  \nf(n) ≤ c * g(n)  \nIn other words, sooner or later g(n) overtakes f(n) as n gets large.  \n• Example: f(n) = n+5; g(n) = n. Show that f(n) = O(g(n)) .  \nChoose c = 6:  \nf(n) = n+5 ≤ 6*n for all n > 0.  \n• Example: f(n) = 17n; g(n) = 3n2 . Show that f(n) = O(g(n)) .  \nChoose c = 6:  \nf(n) = 17n ≤ 6 * 3n2 for all n > 0.  \nAsymptotic Complexity: leading term analysis  \n• Comparing searching and sorting algorithms so far:  \n– Count worst-case number of comparisons as function of array size.  \n– Drop lower-order terms, floors/ceilings, and constants to come up with asymptotic running time of algorithm.  \n• We will now generalize this approach to other programs:  \n– Count worst-case number of operations executed by program as a function of input size.  \n– Formalize definition of big-O complexity to derive asymptotic running time of algorithm.  \n• To prove that f(n) = O(g(n)), find an n0 and c such that f(n) ≤ c * g(n) for all n > n0 .  \n• We will call the pair (c, n0) a witness pair for proving that f(n) = O(g(n)).  \n• For asymptotic complexity, base of logarithms does not matter.  \n• Let us show that log2(n) = O(logb(n)) for any b > 1.  \n• Need to find a witness pair (c, n0) such that: log2(n) ≤ c * logb (n) for all n > n0.  \n• Choose (c = log2 (b), n0 = 0).  \n• This works because  \nc * logb(n) = log2(b) * logb(n)  \n= log2(blogb(n))  \n= log2(n) for all positive n.  \nWhat are the basic OPERATIONS?  \n• For searching and sorting algorithms, you can usually determine big-O complexity by counting comparisons.  \n• Why?  \n• Usually end up doing some fixed number of arithmetic and/or logical operations per comparison.  \n• Why don’t we count swaps for sorting?  \n– e.g., think about selection sort:  \n• max of n swaps  \n• but must do O(n2 ) comparisons  \n• swaps and comparisons have similar cost  \n• Is counting number of comparisons always right?  \n– No.  \n– e.g., selection sort on linked lists instead of arrays  \nWhy is Asymptotic Complexity So Important?  \n• Asymptotic complexity gives an idea of how rapidly the space/time requirements grow as problem size increases.  \n• Suppose we have a computing device that can execute 1000 complex operations per second. Here is the size problem that can be solved ina second, a minute, and an hour by algorithms of different asymptotic complexity:  \n\n| Complexity | 1 second | 1 minute | 1 hour |\n| --- | --- | --- | --- |\n| n | 1000 | 60,000 | 3,600,000 |\n| n log n | 140 | 4893 | 200,000 |\n| n2 | 31 | 244 | 1897 |\n| 3n2 | 18 | 144 | 1096 |\n| n3 | 10 | 39 | 153 |\n| 2n | 9 | 15 | 21 |\n\nWhat Operations Should We Count?  \n• Must do a detailed counting of all executed operations.  \n• Estimate number of primitive operations that RAM model (basic microprocessor) must do to run program:  \n– Basic operation: arithmetic/logical operations count as 1 operation.  \n• even though adds, multiplies, and divides don’t (usually) cost the same  \n– Assignment: counts as 1 operation.  \n• operation count of righthand side of expression is determined separately.  \n– Loop: number of operations per iteration * number of loop iterations.  \n– Method invocation: number of operations executed in the invoked method.  \n• ignore costs of building stack frames,…  \n– Recursion: same as method invocation, but harder to reason about.  \n– Ignoring garbage collection, memory hierarchy (caches),…  \n\n| Example: Selection Sort\u003Cbr>public static void selectionSort(Comparable[] a) { //array of size n |  |\n| --- | --- |\n| for (int i = 0; i \u003C a.length; i++) { int MinPos = i;\u003Cbr>for (int j = i+1; j \u003C a.length; j++) { if (a[j].compareTo(a[MinPos]) \u003C 0)\u003Cbr>MinPos = j;} Comparable temp = a[i];\u003Cbr>a[i] = a[MinPos]; a[MinPos] = temp;}} | \u003C --cost = c1, n times\u003Cbr>\u003C --cost = c2, n times\u003Cbr>\u003C --cost = c3, n*(n-1","cbCaidweyTj9PrCf","https://ap.wps.com/l/cbCaidweyTj9PrCf","pdf",253620,8,"English","# Formal Definition of big-O Notation\n## Asymptotic Complexity: leading term analysis\n## What are the basic OPERATIONS?\n## Why is Asymptotic Complexity so important?\n## What Operations Should We Count?\n## Remarks on counting operations\n## Analysis of Merge-Sort","[{\"question\":\"How do you prove that f(n) = O(g(n))?\",\"answer\":\"Find constants c and n0 such that f(n) ≤ c·g(n) for all n \\u003e n0. The pair (c, n0) is called a witness pair.\"},{\"question\":\"Why can lower-order terms, floors/ceilings, and constants be ignored?\",\"answer\":\"Asymptotic running time focuses on growth as n becomes large. Once the leading term dominates, those details do not change the big-O classification.\"},{\"question\":\"What basic operations are commonly counted when analyzing searching and sorting?\",\"answer\":\"For searching and sorting algorithms, big-O is usually determined by counting worst-case comparisons. Typically, each comparison triggers a fixed number of primitive arithmetic/logical operations.\"}]","Asymptotic Running Time of Algorithms - Formal Definition of big-O Notation - leading term analysis | PDF",1791939576]