{"id":24476,"date":"2020-10-19T10:38:16","date_gmt":"2020-10-19T17:38:16","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=24476"},"modified":"2022-07-20T08:35:10","modified_gmt":"2022-07-20T15:35:10","slug":"python-algorithms","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-algorithms\/","title":{"rendered":"Python Algorithms"},"content":{"rendered":"\n<p>Algorithms are well defined instructions used to solve problems. Imagine you live on the second floor of a building and you needed to give yourself instructions to check your mail. Your algorithm would look something like this:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>stand_up()\nfind_mailbox_key()\ntake_mailbox_key()\ngo_to_front_door()\nopen_front_door()\nexit_apartment()\nclose_front_door()\ngo_down_stairs()\ngo_to_front_door()\nopen_front_door()\nexit_building()\nclose_front_door()\nfind_mailbox()\nunlock_mailbox_with_mailbox_key()\nopen_maibox()\ncheck_for_mail()<\/pre><\/div>\n\n\n\n<p>Notice that we needed to be very well defined in our instructions. We cannot exit the apartment without opening the door. Omitting one instruction can prevent developers from solving a problem.<br><\/p>\n\n\n\n<p>There are several different types of algorithms in python. Some of which can help solve problems more quickly than others. We measure this using the Big-O notation.<br><\/p>\n\n\n\n<p>In this article, we dive into different types of sorting algorithms while measuring their efficiency, or Big-O notation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Sorting Algorithms<\/h2>\n\n\n\n<p>Sorting algorithms are building block algorithms which many other algorithms can build upon. Sorting algorithms are used to solve problems like searching for an item(s) on a list, selecting an item(s) from a list, and distributions. Solving these problems is much faster with sorting.&nbsp;<br><\/p>\n\n\n\n<p>Imagine you have a walk-in closet that is not only organized in terms of casual, active-wear, and business, but is also color coordinated. How much faster would it be to find your blue gym shorts in the list that is your closet versus an unorganized, or unsorted closet?&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python\u2019s Built-In Sorting Algorithm<\/h3>\n\n\n\n<p>Python does have a built-in sorting algorithm, <code>sorted()<\/code>, that can be used for lists.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>list = [5, 45, 22 , 3, 9, 0, 12, 6, 1]\n \nprint(sorted(list))\n# prints [0, 1, 3, 5, 6, 9, 12, 22, 45]<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Bubble Sort<\/h3>\n\n\n\n<p>Bubble sort is the simplest, but very slow, sorting algorithm, with a <a href=\"https:\/\/careerkarma.com\/blog\/big-o-notation-time\/\">Big-O notation<\/a> of O(n^2). We will learn more about Big-O later. For now, let\u2019s go through the list multiple times, comparing elements one by one, and swapping them accordingly. Take the example below.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/EA6CmejAIQ9QEoQCoGWTVA84Oa-chkJNXniqTP4x2qsrdXsiaRsMumh01S2gMmFaOgooEXQjU9z3FnEckV1DuF38b-K3XOmHzN3rA2g1kQTglDAX17k5sfXFR18he30mKnrHmxFV\" alt=\"\"\/><\/figure>\n\n\n\n<p>Notice how every time we have to iterate through the list, the section of the list we need to iterate through gets smaller because the items on the right (in orange) have already been sorted. Below is an explanation of what is happening with our bubble sort visualization above.&nbsp;<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre># initial list, compare 29 &amp; 10\n[29, 10, 15, 32, 10]\n# 29 &gt; 10, so we swap &amp; compare 29 &amp; 15\n[10, 29, 15, 32, 10]\n# 29 &gt; 15, so we swap &amp; compare 29 &amp; 32\n[10, 15, 29, 32, 10]\n# 29 &lt; 32, so we compare 32 &amp; 10\n[10, 15, 29, 32, 10]\n# 32 &gt; 10, so we swap\n[10, 15, 29, 10, 32]\n# Begin again from the first element, compare 10 &amp; 15\n[10, 15, 29, 10, 32]\n# 10 &lt; 15, so we compare 15 &amp; 29\n[10, 15, 29, 10, 32]\n# 15 &lt; 29, so we compare 29 &amp; 10\n[10, 15, 29, 10, 32]\n# 29 &gt; 15, so we swap &amp; compare 29 &amp; 32\n[10, 15, 10, 29, 32]\n# Begin again, from the first element compare 10 &amp; 15\n[10, 15, 10, 29, 32]\n# 10 &lt; 15, so we compare 15 &amp; 10\n[10, 15, 10, 29, 32]\n# 15 &gt; 10, so we swap\n[10, 10, 15, 29, 32]\n# Begin again from the first element, list is now sorted\n[10, 10, 15, 29, 32]<\/pre><\/div>\n\n\n\n<p>The code for bubble sort would like something like the below example code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def bubble_sort(list):\n    # Traverse (travel across) through every element on the list\n    for i in range(0, len(list) - 1):\n        # Compare each item in list 1 by 1. Comparison in each iteration \n        # will shorten as the last elements become sorted\n        for j in range(0, len(list) - 1 - i):\n            # traverse the list from 0 to n-i-1 \n            # if the element found is greater than the next element, swap\n            if list[j] &gt; list[j + 1]:\n                list[j], list[j + 1] = list[j + 1], list[j]\n \n    return list\n \nprint(bubble_sort([2, 3, 7, 1, 9, 5]))<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Insertion Sort<\/h3>\n\n\n\n<p>If you have ever played poker, you most likely have used this sorting method. With the insertion sort, you would begin with one card in your hand, pick the next random card, insert it in the correct sorted order, and repeat.<br><\/p>\n\n\n\n<p>Insertion sort\u2019s algorithm runs in O(n) time, best case, and O(n^2) worst case.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/Upip8gpI1oGSFaGZbPoI2Xe63l7EcnxPimhRpPPaG5hoDs5RUdqZEIfb7YGWhFywKLkwlDVQQJvgx3vZadJATJAOMBwNYRqumzXGTMnfN3W83iUAuFc2_pDsmnyNKm9k4y9_kdVm\" alt=\"\"\/><\/figure>\n\n\n\n<p>Below is an explanation of the insertion sort algorithm visualization above.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre># Mark the first element, 10, as sorted\n[10, 3, 2, 6]\n# Look at next element, 3, 3 &lt; 10\n[10, 3, 2, 6]\n# Extract 3 and move it before 10, mark first element, 3 as sorted\n[3, 10, 2, 6]\n# Look at the next unsorted element, 2, 2 &lt; 10, 2 &lt; 3\n[3, 10, 2, 6]\n# Extract 2 and move it before 3, mark first element, 2, as sorted\n[2, 3, 10, 6]\n# Look at the next unsorted element, 6, 6 &lt; 10, 6 &gt; 3\n[2, 3, 10, 6]\n# Extract 6 and move it before 10\n[2, 3, 6, 10]<\/pre><\/div>\n\n\n\n<p>Below is a code example of the insertion sort algorithm.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def insertionSort(list):\n    # all the values after the first\n    index_length = range(1, len(list))\n    # to do an operation on all these values\n    # for all the value is the index_length value,\n    for i in index_length:\n    # we want to sort those values\n        sort = list[i]\n        # while the item to the left is greater than the item\n        # to the right\n        # notice that we also have to write i &gt; 0 bc python allows\n        # for negative indexing\n        while list[i-1] &gt; sort and i &gt; 0:\n            # swap\n            list[i], list[i-1] = list[i-1], list[i]\n            # to continue doing comparisons down the list,\n            # look at the next item\n            i = i - 1\n \n    return list\n \nprint(insertionSort([7, 3, 4, 1, 9]))<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Merge Sort<\/h3>\n\n\n\n<p>Merge sort has a divide and conquer approach to sorting, and is a recursive sorting algorithm, different from the ones above which are iterative. To understand merge sort, we must first understand recursion.<br><\/p>\n\n\n\n<p>Recursive functions are functions that call themselves, but have a base case to work towards to prevent infinite loops. Below is a code example of a basic recursive function.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>def recursive(n):\n    # This is the base case we are working towards\n    # When we get to where n==0, we return 1\n    if n == 0:\n        return 1\n    # here we move towards the base case\n    return n * recursive(n - 1)<\/pre><\/div>\n\n\n\n<p>In merge sort, we begin sorting pair by pair until everything is in order and we are able to merge. Take the visualization below.<br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/iz8kE8XQv58nWTQ63VsFF-umZ5rdnyRTQ4Gv8B98b7N4tDs_2ji4m4_JTUuRrsMGDTfndl1uT6pUHZa0Ri4UfUwGGsOLU7RpMouCb3JWQGiqPSUkbYNVpa4CHefrcRxqOVcQ8V5T\" alt=\"\"\/><\/figure>\n\n\n\n<p>First we compare the first two indexes and sort them, before we move on to the next two.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/clAumSPmBvbVtepF_8Xl-IPl2Kh_gHzpThog0jH40T0ba7-oJRHWDxCsl1p3xNfkByWpgnr20IOhF6q9EyzmBVUeLMKiL33k24PCT0l8G6g0VXiRTj62R9lg5UU_ZsdpdaO5YqKL\" alt=\"\"\/><\/figure>\n\n\n\n<p>Second, we begin by comparing the first index of the first two groups, sorting along the way, before we move right again.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 3<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/o39N9kbi_4KA4OUBQ4M6HejjQOnzglY_k3wOg3ReCZrkn1W1gc90ctO7X6Rvz4elLifeTo9EmsNbSB8S4fzjsuJJK-2KAdjGOipd0jvr4TH6xuqnni9xFZbZNH5bAnb43EXRpdo-\" alt=\"\"\/><\/figure>\n\n\n\n<p>Lastly, we move across the indexes of the two groups, comparing and sorting the values before we move right.<br><\/p>\n\n\n\n<p>Below is a code example of merge sort.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre># bc there are multiple steps in the divide and conquer approach\n# we need multiple function definitions\n \n# helper function\ndef merge(left, right):\n    elements = len(left) + len(right)\n    merged_list = [0] * elements\n \n    left_pointer = 0\n    right_pointer = 0\n    i = 0\n \n    # while there are elements in either list\n    while left_pointer &lt; len(left) or right_pointer &lt; len(right):\n        # if there are elements in both lists\n        if left_pointer &lt; len(left) and right_pointer &lt; len(right):\n            if left[left_pointer] &lt; right[right_pointer]:\n                merged_list[i] = left[left_pointer]\n                left_pointer += 1\n            else:\n                merged_list[i] = right[right_pointer]\n                right_pointer += 1\n            i += 1\n        # if there are only elements in the left list\n        elif left_pointer &lt; len(left):\n            merged_list[i] = left[left_pointer]\n            left_pointer += 1\n            i += 1\n        # if there are only elements in the right list\n        elif right_pointer &lt; len(right):\n            merged_list[i] = right[right_pointer]\n            right_pointer += 1\n            i += 1\n    return merged_list\n \n# sort function\ndef merge_sort(list):\n    if len(list) &lt;= 1:\n        return list\n    else:\n        mid = (len(list)) \/\/ 2\n        left_array = list[:mid]\n        right_array = list[mid:]\n \n        left_array = merge_sort(left_array)\n        right_array = merge_sort(right_array)\n        result = merge(left_array, right_array)\n \n        return result\n \n \n# in-place merge sort algorithm\ndef merge_in_place(list, begin, mid, end):\n    begin_high = mid + 1\n \n    # if mid and begin_high are already in order, return\n    if list[mid] &lt;= list[begin_high]:\n        return\n    # while pointers are within bounds\n    while begin &lt;= mid and begin_high &lt;= end:\n        # if begin element is in order w\/ respect to begin_high element\n        if list[begin] &lt;= list[begin_high]:\n            # increment begin\n            begin += 1\n        else:\n            # current value is at begin of begin_high\n            value = list[begin_high]\n            # index is begin_high\n            index = begin_high\n \n            # while index is not equal to begin\n            while index != begin:\n                # swap item at index with it's left-neighbor\n                list[index] = list[index-1]\n                # decrement index\n                index -= 1\n            # value at list begin is new value\n            list[begin] = value\n            # increment all pointers (minus end)\n            begin += 1\n            mid += 1\n            begin_high += 1\n \n# sorting in place\ndef merge_sort_in_place(list, left, right):\n    if left &lt; right:\n        mid = (left + right) \/\/ 2\n \n        merge_sort_in_place(list, left, mid)\n        merge_sort_in_place(list, mid+1, right)\n \n        merge_in_place(list, left, mid, right)\n \n    return list\n \n \nlist = [6, 3, 1, 4, 8, 2, 5, 7]\nresult = merge_sort_in_place(list, 0, len(list)-1)\nprint(result)<\/pre><\/div>\n\n\n\n<p>Since we must divide and then conquer with merge sort, we can think of its runtime complexity as O(log(n)) * O(n) or O(n * log(n)). For additional information on Big O notation, check out the Career Karma articles, <a href=\"https:\/\/careerkarma.com\/blog\/big-o-notation-time\/\">Big-O Notation Time <\/a>and <a href=\"https:\/\/careerkarma.com\/blog\/big-o-notation-space\/\">Big-O Notation Space<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"Algorithms are well defined instructions used to solve problems. Imagine you live on the second floor of a building and you needed to give yourself instructions to check your mail. Your algorithm would look something like this: stand_up() find_mailbox_key() take_mailbox_key() go_to_front_door() open_front_door() exit_apartment() close_front_door() go_down_stairs() go_to_front_door() open_front_door() exit_building() close_front_door() find_mailbox() unlock_mailbox_with_mailbox_key() open_maibox() check_for_mail() Notice that&hellip;","protected":false},"author":91,"featured_media":24477,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-24476","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Algorithms: A Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Algorithms are well defined instructions used to solve problems. Learn about how to implement them using Python with this article by Career Karma.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-algorithms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Algorithms\" \/>\n<meta property=\"og:description\" content=\"Algorithms are well defined instructions used to solve problems. Learn about how to implement them using Python with this article by Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-algorithms\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-19T17:38:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-20T15:35:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"681\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kelly M.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/misskellymore\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kelly M.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/\"},\"author\":{\"name\":\"Kelly M.\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/1cc6a89c78a56b632b6032b3b040c4fb\"},\"headline\":\"Python Algorithms\",\"datePublished\":\"2020-10-19T17:38:16+00:00\",\"dateModified\":\"2022-07-20T15:35:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/\"},\"wordCount\":630,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/\",\"name\":\"Python Algorithms: A Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg\",\"datePublished\":\"2020-10-19T17:38:16+00:00\",\"dateModified\":\"2022-07-20T15:35:10+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/1cc6a89c78a56b632b6032b3b040c4fb\"},\"description\":\"Algorithms are well defined instructions used to solve problems. Learn about how to implement them using Python with this article by Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg\",\"width\":1020,\"height\":681,\"caption\":\"lego-Stormtrooper-walking-on-sand\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-algorithms\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Algorithms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/1cc6a89c78a56b632b6032b3b040c4fb\",\"name\":\"Kelly M.\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/kelly-moreira-150x150.jpeg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/kelly-moreira-150x150.jpeg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/kelly-moreira-150x150.jpeg\",\"caption\":\"Kelly M.\"},\"description\":\"Kelly is a technical writer at Career Karma, where she writes tutorials on a variety of topics. She attended the University of Central Florida, earning a BS in Business Administration. Shortly after, she attended Lambda School, specializing in full stack web development and computer science. Before joining Career Karma in September 2020, Kelly worked as a Developer Advocate at Dwolla and as a team lead at Lambda School. Her technical writing can be found on Codecademy, gitConnected, and JavaScript in Plain English.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/kemore\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/misskellymore\"],\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/kelly-m\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Algorithms: A Complete Guide | Career Karma","description":"Algorithms are well defined instructions used to solve problems. Learn about how to implement them using Python with this article by Career Karma.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/python-algorithms\/","og_locale":"en_US","og_type":"article","og_title":"Python Algorithms","og_description":"Algorithms are well defined instructions used to solve problems. Learn about how to implement them using Python with this article by Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/python-algorithms\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-19T17:38:16+00:00","article_modified_time":"2022-07-20T15:35:10+00:00","og_image":[{"width":1020,"height":681,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg","type":"image\/jpeg"}],"author":"Kelly M.","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/misskellymore","twitter_site":"@career_karma","twitter_misc":{"Written by":"Kelly M.","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/"},"author":{"name":"Kelly M.","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/1cc6a89c78a56b632b6032b3b040c4fb"},"headline":"Python Algorithms","datePublished":"2020-10-19T17:38:16+00:00","dateModified":"2022-07-20T15:35:10+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/"},"wordCount":630,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-algorithms\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/","url":"https:\/\/careerkarma.com\/blog\/python-algorithms\/","name":"Python Algorithms: A Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg","datePublished":"2020-10-19T17:38:16+00:00","dateModified":"2022-07-20T15:35:10+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/1cc6a89c78a56b632b6032b3b040c4fb"},"description":"Algorithms are well defined instructions used to solve problems. Learn about how to implement them using Python with this article by Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-algorithms\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/daniel-cheung-cPF2nlWcMY4-unsplash.jpg","width":1020,"height":681,"caption":"lego-Stormtrooper-walking-on-sand"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-algorithms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Algorithms"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/1cc6a89c78a56b632b6032b3b040c4fb","name":"Kelly M.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/kelly-moreira-150x150.jpeg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/kelly-moreira-150x150.jpeg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/kelly-moreira-150x150.jpeg","caption":"Kelly M."},"description":"Kelly is a technical writer at Career Karma, where she writes tutorials on a variety of topics. She attended the University of Central Florida, earning a BS in Business Administration. Shortly after, she attended Lambda School, specializing in full stack web development and computer science. Before joining Career Karma in September 2020, Kelly worked as a Developer Advocate at Dwolla and as a team lead at Lambda School. Her technical writing can be found on Codecademy, gitConnected, and JavaScript in Plain English.","sameAs":["https:\/\/www.linkedin.com\/in\/kemore\/","https:\/\/x.com\/https:\/\/twitter.com\/misskellymore"],"url":"https:\/\/careerkarma.com\/blog\/author\/kelly-m\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/24476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/91"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=24476"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/24476\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/24477"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=24476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=24476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=24476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}