[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-573425-105":3,"detail-sidebar-cat-1-en-105":79,"doc-detail-573425-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","algorithms-cs50-cheat-sheet-quick-reference-for-key-concepts","Algorithms (CS50) Cheat Sheet - Quick Reference for Key Concepts","","Algorithms (CS50) cheat sheet provides concise definitions and practical notes on core CS50 topics. It explains what an algorithm is, compares linear and binary search with best and worst case time complexities, and summarizes common sorting methods including bubble sort, selection sort, and merge sort. It also covers Big-O notation fundamentals and recursion, including base vs recursive cases and a factorial example with a C implementation.",{"@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/algorithms-cs50-cheat-sheet-quick-reference-for-key-concepts/573425/",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/algorithms-cs50-cheat-sheet-quick-reference-for-key-concepts/573425.png","ImageObject",442,249,{"name":42,"@type":43},"4398046744996","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 is an algorithm according to the cheat sheet?","Question",{"text":61,"@type":62},"An algorithm is defined as a step-by-step set of instructions for completing a task.","Answer",{"name":64,"@type":59,"acceptedAnswer":65},"How do linear search and binary search differ in efficiency?",{"text":66,"@type":62},"Linear search runs in O(n) worst case and Ω(1) best case, while binary search runs in O(log n) worst case with Ω(1) best case when the target is the middle.",{"name":68,"@type":59,"acceptedAnswer":69},"What are the base case and recursive case in recursion?",{"text":70,"@type":62},"The base case terminates the recursive process, while the recursive case causes the function to invoke itself. The cheat sheet illustrates this with a factorial example and its C code.","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},573425,1792015952,{"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":11,"doc_module":22,"category_id":83,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":128,"file_id":129,"file_url":130,"file_type":131,"file_size":132,"view_count":22,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":22,"language":133,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":134,"faqs":135,"seo_title":136,"seo_description":12,"update_tm":137,"read_time":4},4398046744996,"Algorithms (CS50) Cheat Sheet  \n[by](by dmytronoks via cheatography.com/158792/cs/33506/)[ dmytronoks](by dmytronoks via cheatography.com/158792/cs/33506/)[ via](by dmytronoks via cheatography.com/158792/cs/33506/)[ cheatography.com/158792/cs/33506/](by dmytronoks via cheatography.com/158792/cs/33506/)  \nDefinition  \n\n|  |  |\n| --- | --- |\n| Algorithm is a step-by-step set of instructions for completing a task. |  |\n| Search Algorithms |  |\n| Linear Search: Iterate across | Worst case O(n): the target element |\n| the array from left to right , | is the last element of the array or it |\n| searching for a specified | doesn’t exist at all. Best case Ω(1): |\n| element. | the target element is the first element of the array. |\n| Binary Search: Divide and | Worst case O(log n): the target |\n| conquer, reducing the search | element will be found at the end of |\n| area by half each time , trying | the last division or it won’t be found |\n| to find a target number. First , | at all. Best case Ω(1): the target |\n| the array should be sorted. | element is the mid-point of the full\u003Cbr>array. |\n| Sorting Algorithms |  |\n\nBubble Sort: Swapping pairs of two elements: higher valued elements towards the right and the lower valued elements towards the left.  \nWorst case O(n^2): the array is in the reversed order. Best case Ω(1): the array is already perfectly sorted and we don’t need to make any swaps on the first run.  \nSelection Sort: Find the smallest unsorted element and add it to the end of the sorted list.  \nWorst case O(n2): iterate over each of the n elements of the array (to find the smallest unsorted element) → it’s at the very end of the array and repeat this proces n times , since only one element gets sorted on each pass. Best case Ω(n2): exactly the same!  \nMerge Sort: Sort smaller arrays and then merge them in sorted order.  \nThe best and the worst cases are the same:  \nn log n .  \nBig O notation  \n\n|  |\n| --- |\n| Big-O notation is a simplified analysis of an algorithm’s efficiency. It attempts to answer two questions:\u003Cbr>Q1: how much memory is needed?\u003Cbr>Q2: how much time does it take to complete? |\n| Recursion |\n| \u003Cbr>A recursive function is one that , as part of its execution , invokes itself.\u003Cbr>Every recursive function has two cases that could apply , given any input:\u003Cbr>-The base case → terminate the recursive process\u003Cbr>-The recursive case → the recursion occurs\u003Cbr>Example of recursion: the factorial function |\n\nThe factorial is found by multiplying n by all the whole numbers less than it.  \nExample:  \n5! = 5 x 4 x 3 x 2 x 1 = 120  \nIn C:  \nint fact (int n)  \n{  \nif (n == 1)  \nreturn 1 ; else  \nreturn n * fact (n-1);}  \nScenario A: The function calls itself in the 'else' clause → recursive case  \nScenario B: The function terminates in the 'if' clause → base case  \n By dmytronoks  \n[cheatography.com/dmytronoks/](cheatography.com/dmytronoks/)  \nPublished 5th August , 2022. Last updated 4th August , 2022. Page 1 of 1.  \nSponsored by CrosswordCheats.com Learn to solve cryptic crosswords!  \n[http://crosswordcheats.com](http://crosswordcheats.com)","cbCaiccRolhHeb2a","https://ap.wps.com/l/cbCaiccRolhHeb2a","pdf",41534,"English","# Definition\n# Search Algorithms\n## Linear Search\n## Binary Search\n# Sorting Algorithms\n## Bubble Sort\n## Selection Sort\n## Merge Sort\n# Big O notation\n# Recursion","[{\"question\":\"What is an algorithm according to the cheat sheet?\",\"answer\":\"An algorithm is defined as a step-by-step set of instructions for completing a task.\"},{\"question\":\"How do linear search and binary search differ in efficiency?\",\"answer\":\"Linear search runs in O(n) worst case and Ω(1) best case, while binary search runs in O(log n) worst case with Ω(1) best case when the target is the middle.\"},{\"question\":\"What are the base case and recursive case in recursion?\",\"answer\":\"The base case terminates the recursive process, while the recursive case causes the function to invoke itself. The cheat sheet illustrates this with a factorial example and its C code.\"}]","Algorithms (CS50) Cheat Sheet - Quick Reference for Key Concepts | PDF",1791939569]