{"id":48522,"date":"2025-05-08T14:38:32","date_gmt":"2025-05-08T09:08:32","guid":{"rendered":"https:\/\/www.iquanta.in\/blog\/?p=48522"},"modified":"2025-05-08T18:11:58","modified_gmt":"2025-05-08T12:41:58","slug":"merge-sort-algorithm-with-complexity-analysis-working","status":"publish","type":"post","link":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/","title":{"rendered":"Merge Sort Algorithm with Complexity Analysis &amp; Working"},"content":{"rendered":"\n<p>As we have already covered two algorithms those are <a href=\"https:\/\/www.iquanta.in\/blog\/bubble-sort-algorithm-with-complexity-analysis\/#:~:text=Step%2Dby%2DStep%20Working%20of%20Bubble%20Sort%20Algorithm&amp;text=Compare%20the%20first%20two%20elements,array%20%E2%80%94%20this%20completes%20one%20pass.\">Bubble Sort algorithm <\/a>and Insertion Sort along with their implementation. In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works. With the Merge Sort Algorithm we will compare all other algorithms to check their time complexities and space complexities. Let&#8217;s explore this algorithm and understand how everything will go with the process and its working.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_77 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#What_is_Merge_Sort_Algorithm\" >What is Merge Sort Algorithm?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Example\" >Example:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Key_Features_of_Merge_Sort_Algorithm\" >Key Features of Merge Sort Algorithm<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#How_Merge_Sort_Works\" >How Merge Sort Works?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Divide_the_Array\" >Divide the Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Conquer_by_Sorting\" >Conquer by Sorting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Combine_by_Merging\" >Combine by Merging<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Merge_Sort_Algorithm_Implementation_in_Python\" >Merge Sort Algorithm Implementation in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Example_of_Merge_Sort_Algorithm\" >Example of Merge Sort Algorithm<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Step_1_Divide_the_array\" >Step 1: Divide the array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Step_2_Merge_and_sort_the_smaller_arrays\" >Step 2: Merge and sort the smaller arrays<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Step_3_Final_Merge\" >Step 3: Final Merge<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Merge_Sort_without_Recursion\" >Merge Sort without Recursion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Advantages_of_Merge_Sort_Algorithm\" >Advantages of Merge Sort Algorithm<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#Disadvantages_of_Merge_Sort_Algorithm\" >Disadvantages of Merge Sort Algorithm<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-merge-sort-algorithm\"><span class=\"ez-toc-section\" id=\"What_is_Merge_Sort_Algorithm\"><\/span><strong>What is Merge Sort Algorithm?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Merge Sort Algorithm is a classic divide and conquer sorting technique used in computer science to arrange elements in a specific order typically ascending or descending. It works by recursively breaking down a list into smaller sublists until each sublist contains a single element and then merging those sublists in a manner that results in a sorted list.<\/p>\n\n\n\n<p>Here&#8217;s how the merge sort algorithm works step by step &#8211; <\/p>\n\n\n\n<ol>\n<li>Divide: Split the array into two halves.<\/li>\n\n\n\n<li>Conquer: Recursively sort each half using merge sort.<\/li>\n\n\n\n<li>Combine: Merge the two sorted halves into one sorted array.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example\"><\/span>Example:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Consider an unsorted array: [38, 27, 43, 3, 9, 82, 10]<\/p>\n\n\n\n<ul>\n<li>First it will split into [38, 27, 43] and [3, 9, 82, 10]<\/li>\n\n\n\n<li>Each part is further divided and sorted individually.<\/li>\n\n\n\n<li>Finally, the sorted subarrays are merged to form [3, 9, 10, 27, 38, 43, 82]<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Key_Features_of_Merge_Sort_Algorithm\"><\/span><strong>Key Features of Merge Sort Algorithm<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>Time Complexity: O(n log n) in the worst, average, and best case.<\/li>\n\n\n\n<li>Space Complexity: O(n) due to the temporary arrays used during merging.<\/li>\n\n\n\n<li>Stable Sort: It preserves the relative order of equal elements.<\/li>\n\n\n\n<li>Not In Place: Requires additional memory for merging.<\/li>\n<\/ul>\n\n\n\n<p>The merge sort algorithm is especially useful for large datasets where a stable and predictable time complexity is crucial.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-merge-sort-works\"><span class=\"ez-toc-section\" id=\"How_Merge_Sort_Works\"><\/span><strong>How Merge Sort Works?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To understand how the merge sort algorithm works, imagine splitting a problem into smaller parts, solving each part, and then combining the solutions. That is the essence of the merge sort technique.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"952\" src=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-1024x952.png\" alt=\"merge sort algorithm\" class=\"wp-image-48533\" style=\"width:601px;height:auto\" srcset=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-1024x952.png 1024w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-300x279.png 300w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-768x714.png 768w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-452x420.png 452w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-150x140.png 150w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-696x647.png 696w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37-1068x993.png 1068w, https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/image-37.png 1086w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>Here is a step by step breakdown of how the merge sort algorithm works &#8211;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Divide_the_Array\"><\/span><strong>Divide the Array<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The array is recursively divided into two halves until each sub-array contains only a single element (or is empty). At this stage, every sub-array is trivially sorted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conquer_by_Sorting\"><\/span><strong>Conquer by Sorting<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Once the array is divided down to single elements, the merge sort algorithm begins to merge the sub-arrays. But instead of simply combining them, it compares the elements and sorts them during the merging process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Combine_by_Merging\"><\/span><strong>Combine by Merging<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Two sorted sub-arrays are merged into one sorted array. This merging continues up the recursive chain until the entire array is reassembled in sorted order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-merge-sort-algorithm-implementation-in-python\"><span class=\"ez-toc-section\" id=\"Merge_Sort_Algorithm_Implementation_in_Python\"><\/span><strong>Merge Sort Algorithm Implementation in Python<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def merge_sort(arr):\r\n    if len(arr) &gt; 1:\r\n        # Finding the middle of the array\r\n        mid = len(arr) \/\/ 2\r\n\r\n        # Dividing the array elements into 2 halves\r\n        left_half = arr&#091;:mid]\r\n        right_half = arr&#091;mid:]\r\n\r\n        # Recursively sort both halves\r\n        merge_sort(left_half)\r\n        merge_sort(right_half)\r\n\r\n        # Merging the sorted halves\r\n        i = j = k = 0\r\n\r\n        # Copy data to temp arrays left_half&#091;] and right_half&#091;]\r\n        while i &lt; len(left_half) and j &lt; len(right_half):\r\n            if left_half&#091;i] &lt; right_half&#091;j]:\r\n                arr&#091;k] = left_half&#091;i]\r\n                i += 1\r\n            else:\r\n                arr&#091;k] = right_half&#091;j]\r\n                j += 1\r\n            k += 1\r\n\r\n        # Checking if any element was left in left_half\r\n        while i &lt; len(left_half):\r\n            arr&#091;k] = left_half&#091;i]\r\n            i += 1\r\n            k += 1\r\n\r\n        # Checking if any element was left in right_half\r\n        while j &lt; len(right_half):\r\n            arr&#091;k] = right_half&#091;j]\r\n            j += 1\r\n            k += 1\r\n\r\n# Example usage\r\nsample_array = &#091;38, 27, 43, 3, 9, 82, 10]\r\nprint(\"Original array:\", sample_array)\r\nmerge_sort(sample_array)\r\nprint(\"Sorted array:\", sample_array)\n\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-example-of-merge-sort-algorithm\"><span class=\"ez-toc-section\" id=\"Example_of_Merge_Sort_Algorithm\"><\/span><strong>Example of Merge Sort Algorithm<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We are Choosing array [19, 7, 18, 9, 4, 7, 14, 9] and with this array we are performing merge sort algorithm<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Divide_the_array\"><\/span>Step 1: Divide the array<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Split the array into halves until each sub-array contains a single element.<\/p>\n\n\n\n<p>[19, 7, 18, 9, 4, 7, 14, 9]<br>\u2192 [19, 7, 18, 9] and [4, 7, 14, 9]<br>\u2192 [19, 7], [18, 9], [4, 7], [14, 9]<br>\u2192 [19]  [7]  [18]  [9]  [4]  [7]  [14]  [9]  (Splitted the complete array in sub arrays)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Merge_and_sort_the_smaller_arrays\"><\/span>Step 2: Merge and sort the smaller arrays<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Start merging while sorting:<\/p>\n\n\n\n<ul>\n<li>[19] + [7] \u2192 [7, 19]<\/li>\n\n\n\n<li>[18] + [9] \u2192 [9, 18]<\/li>\n\n\n\n<li>[4] + [7] \u2192 [4, 7]<\/li>\n\n\n\n<li>[14] + [9] \u2192 [9, 14]<\/li>\n<\/ul>\n\n\n\n<p>Now merge again this &#8211;<\/p>\n\n\n\n<ul>\n<li>[7, 19] + [9, 18] \u2192 [7, 9, 18, 19]<\/li>\n\n\n\n<li>[4, 7] + [9, 14] \u2192 [4, 7, 9, 14]<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Final_Merge\"><\/span>Step 3: Final Merge<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>[7, 9, 18, 19] + [4, 7, 9, 14]<br>\u2192 Compare and merge:<br>\u2192 [4, 7, 7, 9, 9, 14, 18, 19]<\/li>\n\n\n\n<li>Final Sorted Output<\/li>\n<\/ul>\n\n\n\n<p>4  7  7  9  9  14  18  19<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-merge-sort-without-recursion\"><span class=\"ez-toc-section\" id=\"Merge_Sort_without_Recursion\"><\/span><strong>Merge Sort without Recursion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Merge Sort is a method used to sort numbers by dividing the list into smaller parts and then combining them in the right order. In the non-recursive or iterative version and we start by treating each number as a small sorted list. Then we keep merging pairs of these small lists step by step until the whole list is sorted. This process is repeated by doubling the size of the parts each time. It is a simple and efficient way to sort as even for large lists.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def merge(left, right):\r\n    result = &#091;]\r\n    i = j = 0\r\n\r\n    # Merge the two sorted halves\r\n    while i &lt; len(left) and j &lt; len(right):\r\n        if left&#091;i] &lt;= right&#091;j]:\r\n            result.append(left&#091;i])\r\n            i += 1\r\n        else:\r\n            result.append(right&#091;j])\r\n            j += 1\r\n\r\n    # Add remaining elements (if any)\r\n    result.extend(left&#091;i:])\r\n    result.extend(right&#091;j:])\r\n    return result\r\n\r\ndef merge_sort_iterative(arr):\r\n    n = len(arr)\r\n    width = 1\r\n\r\n    # Iteratively merge subarrays of increasing size\r\n    while width &lt; n:\r\n        for i in range(0, n, 2 * width):\r\n            left = arr&#091;i:i + width]\r\n            right = arr&#091;i + width:i + 2 * width]\r\n            arr&#091;i:i + 2 * width] = merge(left, right)\r\n        width *= 2\r\n\r\n    return arr\r\n\r\n# Example usage\r\narr = &#091;38, 27, 43, 3, 9, 82, 10]\r\nsorted_arr = merge_sort_iterative(arr)\r\nprint(\"Sorted array:\", sorted_arr)\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-advantages-of-merge-sort-algorithm\"><span class=\"ez-toc-section\" id=\"Advantages_of_Merge_Sort_Algorithm\"><\/span><strong>Advantages of Merge Sort Algorithm<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol>\n<li>It always gives the correct sorted result no matter how the input looks.<\/li>\n\n\n\n<li>It is fast and efficient even for large amounts of data.<\/li>\n\n\n\n<li>It does not get worse with messy input like some other sorting methods.<\/li>\n\n\n\n<li>It works well with linked list data structure because of how it divides and merges.<\/li>\n\n\n\n<li>It keeps equal items in the same order as it is a stable sort algorithm.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-disadvantages-of-merge-sort-algorithm\"><span class=\"ez-toc-section\" id=\"Disadvantages_of_Merge_Sort_Algorithm\"><\/span><strong>Disadvantages of Merge Sort Algorithm<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol>\n<li>It uses more memory because it needs extra space to merge arrays.<\/li>\n\n\n\n<li>It can be slower than other sorts like quick sort for small datasets.<\/li>\n\n\n\n<li>It does a lot of splitting and merging which can feel like extra work.<\/li>\n\n\n\n<li>It is not the best choice for low memory devices due to space usage.<\/li>\n\n\n\n<li>It does not sort in place meaning it copies data instead of sorting where it is<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>As we have already covered two algorithms those are Bubble Sort algorithm and Insertion Sort along with their implementation. In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works. With the Merge Sort Algorithm we will compare all other algorithms to check their time complexities and space [&hellip;]<\/p>\n","protected":false},"author":560,"featured_media":48538,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1075,1073],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.4 (Yoast SEO v21.9.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Merge Sort Algorithm with Complexity Analysis &amp; Working - iQuanta<\/title>\n<meta name=\"description\" content=\"In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Merge Sort Algorithm with Complexity Analysis &amp; Working\" \/>\n<meta property=\"og:description\" content=\"In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/\" \/>\n<meta property=\"og:site_name\" content=\"iQuanta\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/iquanta.in\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-08T09:08:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-08T12:41:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/Your-paragraph-text-15.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nidhi Goswami\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nidhi Goswami\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/\"},\"author\":{\"name\":\"Nidhi Goswami\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3\"},\"headline\":\"Merge Sort Algorithm with Complexity Analysis &amp; Working\",\"datePublished\":\"2025-05-08T09:08:32+00:00\",\"dateModified\":\"2025-05-08T12:41:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/\"},\"wordCount\":733,\"publisher\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#organization\"},\"articleSection\":[\"DSA and Competitive Programming\",\"iSkills\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/\",\"url\":\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/\",\"name\":\"Merge Sort Algorithm with Complexity Analysis &amp; Working - iQuanta\",\"isPartOf\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#website\"},\"datePublished\":\"2025-05-08T09:08:32+00:00\",\"dateModified\":\"2025-05-08T12:41:58+00:00\",\"description\":\"In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.iquanta.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Merge Sort Algorithm with Complexity Analysis &amp; Working\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#website\",\"url\":\"https:\/\/www.iquanta.in\/blog\/\",\"name\":\"iQuanta | Cat Preparation Online\",\"description\":\"Building Learning Networks\",\"publisher\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.iquanta.in\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#organization\",\"name\":\"IQuanta\",\"url\":\"https:\/\/www.iquanta.in\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png\",\"contentUrl\":\"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png\",\"width\":525,\"height\":200,\"caption\":\"IQuanta\"},\"image\":{\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/iquanta.in\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3\",\"name\":\"Nidhi Goswami\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g\",\"caption\":\"Nidhi Goswami\"},\"url\":\"https:\/\/www.iquanta.in\/blog\/author\/nidhigoswami\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Merge Sort Algorithm with Complexity Analysis &amp; Working - iQuanta","description":"In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works.","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:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/","og_locale":"en_US","og_type":"article","og_title":"Merge Sort Algorithm with Complexity Analysis &amp; Working","og_description":"In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works.","og_url":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/","og_site_name":"iQuanta","article_publisher":"https:\/\/facebook.com\/iquanta.in","article_published_time":"2025-05-08T09:08:32+00:00","article_modified_time":"2025-05-08T12:41:58+00:00","og_image":[{"width":1600,"height":900,"url":"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2025\/05\/Your-paragraph-text-15.png","type":"image\/png"}],"author":"Nidhi Goswami","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nidhi Goswami","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#article","isPartOf":{"@id":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/"},"author":{"name":"Nidhi Goswami","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3"},"headline":"Merge Sort Algorithm with Complexity Analysis &amp; Working","datePublished":"2025-05-08T09:08:32+00:00","dateModified":"2025-05-08T12:41:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/"},"wordCount":733,"publisher":{"@id":"https:\/\/www.iquanta.in\/blog\/#organization"},"articleSection":["DSA and Competitive Programming","iSkills"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/","url":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/","name":"Merge Sort Algorithm with Complexity Analysis &amp; Working - iQuanta","isPartOf":{"@id":"https:\/\/www.iquanta.in\/blog\/#website"},"datePublished":"2025-05-08T09:08:32+00:00","dateModified":"2025-05-08T12:41:58+00:00","description":"In this blog we are covering Merge Sort Algorithm along with its complexity, how this algorithm actually works.","breadcrumb":{"@id":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.iquanta.in\/blog\/merge-sort-algorithm-with-complexity-analysis-working\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.iquanta.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Merge Sort Algorithm with Complexity Analysis &amp; Working"}]},{"@type":"WebSite","@id":"https:\/\/www.iquanta.in\/blog\/#website","url":"https:\/\/www.iquanta.in\/blog\/","name":"iQuanta | Cat Preparation Online","description":"Building Learning Networks","publisher":{"@id":"https:\/\/www.iquanta.in\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.iquanta.in\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.iquanta.in\/blog\/#organization","name":"IQuanta","url":"https:\/\/www.iquanta.in\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png","contentUrl":"https:\/\/www.iquanta.in\/blog\/wp-content\/uploads\/2018\/08\/IQuanta-1.png","width":525,"height":200,"caption":"IQuanta"},"image":{"@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/iquanta.in"]},{"@type":"Person","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/ec8c8c25d0526dd86557b6fed064f7f3","name":"Nidhi Goswami","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.iquanta.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21d234d87afd924b217d26b25a3cf1ee?s=96&d=mm&r=g","caption":"Nidhi Goswami"},"url":"https:\/\/www.iquanta.in\/blog\/author\/nidhigoswami\/"}]}},"_links":{"self":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts\/48522"}],"collection":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/users\/560"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/comments?post=48522"}],"version-history":[{"count":5,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts\/48522\/revisions"}],"predecessor-version":[{"id":48539,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/posts\/48522\/revisions\/48539"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/media\/48538"}],"wp:attachment":[{"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/media?parent=48522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/categories?post=48522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iquanta.in\/blog\/wp-json\/wp\/v2\/tags?post=48522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}