{"id":149,"date":"2026-07-15T15:03:50","date_gmt":"2026-07-15T15:03:50","guid":{"rendered":"https:\/\/blog.csfree.org\/?p=149"},"modified":"2026-07-15T15:03:50","modified_gmt":"2026-07-15T15:03:50","slug":"merge-sort-explained-logic-code-and-complexity","status":"publish","type":"post","link":"https:\/\/blog.csfree.org\/index.php\/2026\/07\/15\/merge-sort-explained-logic-code-and-complexity\/","title":{"rendered":"Merge Sort Explained: Logic, Code, and Complexity"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Merge Sort Explained: Logic, Code, and Complexity<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">One of the most <strong>effecient <\/strong>way of sorting is <strong>MERGE SORT<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As we have defined before too-<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is Sorting?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">At its core,&nbsp;<strong>sorting<\/strong>&nbsp;is just the process of&nbsp;<strong>arranging&nbsp;<\/strong>a messy collection of items into a specific, meaningful order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are two examples of sorting, we go through every day life:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Numerical Order:<\/strong>&nbsp;Arranging numbers from smallest to largest (1, 2, 3\u2026) or largest to smallest (99, 98, 97\u2026).<\/li>\n\n\n\n<li><strong>Alphabetical Order:<\/strong>&nbsp;Arranging words or strings from A to Z (like a phonebook contact list) or Z to A.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Now, What exactly is a Merge Sort?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Imagine you are handed a massive, messy pile of papers to alphabetize. If you try to sort the whole stack at once, you quickly run out of desk space and patience. What is your natural instinct to stay sane? You split the pile into smaller, manageable stacks. You sort those smaller stacks individually, and then magically enough, you cleanly zip those sorted stacks back together, comparing just the top pages as you go.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That is exactly how <strong>Merge Sort<\/strong> works. In computer science, <strong>Merge Sort <\/strong>is a highly efficient, comparison-based sorting algorithm that operates on the classic &#8220;divide and conquer&#8221; principle. Instead of trying to fix a messy data structure all at once, it recursively splits the unorganized array directly in half until it reaches single-element subarrays, which are inherently sorted. From there, it systematically pairs and zips those sublists back together in perfect order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By utilizing a temporary workspace to execute these precise, balanced merges, it guarantees a highly stable, predictable execution pattern that handles massive datasets flawlessly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why it\u2019s better than Selection Sort:<\/strong> While <strong>Selection Sort <\/strong>stubbornly scans the entire remaining array over and over\u2014taking a massive performance hit as your data grows\u2014Merge Sort works smarter. By breaking the problem down mathematically, it upgrades your speed from a slow quadratic pace to a lightning-fast logarithmic scale, making it the go-to choice for handling large, real-world data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What are its characteristics?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Highly Stable Sorting Method<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Merge Sort <\/strong>is inherently a <strong>stable<\/strong> sorting algorithm. In data structures, stability means that if two elements share identical values, they are guaranteed to maintain their exact original relative order after the sort is complete. During the merging phase, when elements from two halves are compared, the algorithm is structured to favor the element from the left sublist in the event of a tie, successfully preserving its original positioning.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Linear Extra Space Requirements<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Merge Sort <\/strong>is an <strong>out-of-place<\/strong> algorithm. In order to merge two separate, pre-sorted sublists into perfect order without overwriting or destroying data that is still being processed, it must allocate temporary auxiliary memory. Because the amount of extra workspace scales directly with the number of items being sorted, its auxiliary space complexity is <strong>O(n) (Linear Space)<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Perfectly Consistent Time Complexity<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The performance of <strong>Merge Sort <\/strong>is incredibly consistent and completely independent of the initial arrangement of the input data. Whether the data is already perfectly sorted, arranged in absolute reverse order, or completely randomized, the algorithm executes the exact same sequence of structural splits and merges.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Best-Case Time Complexity:<\/strong> <strong>O(<math data-latex=\"nlogn\"><semantics><mrow><mi>n<\/mi><mi>l<\/mi><mi>o<\/mi><mi>g<\/mi><mi>n<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">nlogn<\/annotation><\/semantics><\/math>)<\/strong><\/li>\n\n\n\n<li><strong>Average-Case Time Complexity:<\/strong> <strong>O(<math data-latex=\"nlogn\"><semantics><mrow><mi>n<\/mi><mi>l<\/mi><mi>o<\/mi><mi>g<\/mi><mi>n<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">nlogn<\/annotation><\/semantics><\/math>)<\/strong><\/li>\n\n\n\n<li><strong>Worst-Case Time Complexity:<\/strong> <strong>O(<math data-latex=\"nlogn\"><semantics><mrow><mi>n<\/mi><mi>l<\/mi><mi>o<\/mi><mi>g<\/mi><mi>n<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">nlogn<\/annotation><\/semantics><\/math>)<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Space Complexity: O(n) Auxiliary Space<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Merge Sort <\/strong>is an <strong>out-of-place<\/strong> algorithm that requires extra memory to operate. During the merging phase, it cannot safely overwrite the original array without losing data, so it creates temporary helper arrays to hold and zip the sorted elements back together.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(<strong>Note<\/strong>: If applied to a <strong>Linked List<\/strong>, it can manipulate pointers directly instead of copying data, dropping its extra memory requirement down to a highly efficient <strong>O(<math data-latex=\"nlogn\"><semantics><mrow><mi>n<\/mi><mi>l<\/mi><mi>o<\/mi><mi>g<\/mi><mi>n<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">nlogn<\/annotation><\/semantics><\/math>)<\/strong> for the recursive call stack.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step-By-Step Example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Lets see how, <strong>Merge Sort Algorithm <\/strong>works on a array: <strong><code>[18, 4, 12, 2, 9, 15]<\/code><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\"><strong>Phase 1 : The Divide Phase<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The algorithm keeps cutting the array exactly in half recursively until every single element stands completely alone.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Initial Array:<\/strong> <code>[18, 4, 12, 2, 9, 15]<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>First Split (Split down the middle):<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Left Half: <code>[18, 4, 12]<\/code><\/li>\n\n\n\n<li>Right Half: <code>[2, 9, 15]<\/code><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Sub-Splits:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>[18, 4, 12]<\/code> breaks into <code>[18, 4]<\/code> and <code>[12]<\/code>. Then <code>[18, 4]<\/code> breaks into <strong><code>[18]<\/code><\/strong> and <strong><code>[4]<\/code><\/strong>.<\/li>\n\n\n\n<li><code>[2, 9, 15]<\/code> breaks into <code>[2, 9]<\/code> and <code>[15]<\/code>. Then <code>[2, 9]<\/code> breaks into <strong><code>[2]<\/code><\/strong> and <strong><code>[9]<\/code><\/strong>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Now, every element stands alone: <strong><code>[18]<\/code><\/strong>, <strong><code>[4]<\/code><\/strong>, <strong><code>[12]<\/code><\/strong>, <strong><code>[2]<\/code><\/strong>, <strong><code>[9]<\/code><\/strong>, <strong><code>[15]<\/code><\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Phase 2: The Conquer &amp; Combine Phase<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we recursively zip the pieces back together, comparing the numbers and sorting them as we climb back up.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Step 1: Merge single numbers into pairs<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The isolated singletons are paired up and sorted into small 2-element arrays:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Compare <code>[18]<\/code> and <code>[4]<\/code> \u2192 Merges into <strong><code>[4, 18]<\/code><\/strong><\/li>\n\n\n\n<li>Compare <code>[2]<\/code> and <code>[9]<\/code> \u2192 Merges into <strong><code>[2, 9]<\/code><\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><em>The single elements <code>[12]<\/code> and <code>[15]<\/code> wait for the next step.<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Step 2: Build the sorted halves<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now we merge those 2-element arrays with the remaining single elements to form two sorted 3-element halves:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Left Merge:<\/strong> Combine <code>[4, 18]<\/code> and <code>[12]<\/code> \u2192 Merges into <strong><code>[4, 12, 18]<\/code><\/strong><\/li>\n\n\n\n<li><strong>Right Merge:<\/strong> Combine <code>[2, 9]<\/code> and <code>[15]<\/code> \u2192 Merges into <strong><code>[2, 9, 15]<\/code><\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Step 3 or Final step: The Final Grand Merge<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The two fully sorted halves- <code>[4, 12, 18]<\/code> and <code>[2, 9, 15]<\/code>, are zipped together into the final array. The algorithm looks at the front of both lists, pulling the smaller value each time:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Compare 4 and 2 \u2192 Take <strong>2<\/strong> <code>[2, _, _, _, _, _]<\/code><\/li>\n\n\n\n<li>Compare 4 and 9 \u2192 Take <strong>4<\/strong> <code>[2, 4, _, _, _, _]<\/code><\/li>\n\n\n\n<li>Compare 12 and 9 \u2192 Take <strong>9<\/strong> <code>[2, 4, 9, _, _, _]<\/code><\/li>\n\n\n\n<li>Compare 12 and 15 \u2192 Take <strong>12<\/strong> <code>[2, 4, 9, 12, _, _]<\/code><\/li>\n\n\n\n<li>Compare 18 and 15 \u2192 Take <strong>15<\/strong> <code>[2, 4, 9, 12, 15, _]<\/code><\/li>\n\n\n\n<li>Right list is empty \u2192 Drop in the remaining <strong>18<\/strong> <code>[2, 4, 9, 12, 15, 18]<\/code><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Final Sorted Array:<\/strong> <code>[2, 4, 9, 12, 15, 18]<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the Implementation of <strong>Merge Sort <\/strong>in <strong>C++<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>#include &lt;iostream&gt;\n#include &lt;vector&gt;\n\n\/\/ 1. The COMBINE Phase: Merges two sorted sub-arrays into a single sorted array\nvoid merge(std::vector&lt;int&gt;&amp; arr, int left, int mid, int right) {\n    \/\/ Calculate the sizes of the two sub-arrays\n    int n1 = mid - left + 1;\n    int n2 = right - mid;\n\n    \/\/ Create temporary arrays to hold the split data\n    std::vector&lt;int&gt; leftArr(n1);\n    std::vector&lt;int&gt; rightArr(n2);\n\n    \/\/ Copy data into the temporary helper arrays\n    for (int i = 0; i &lt; n1; i++) leftArr&#91;i] = arr&#91;left + i];\n    for (int j = 0; j &lt; n2; j++) rightArr&#91;j] = arr&#91;mid + 1 + j];\n\n    \/\/ Initial indexes for traversing sub-arrays and the main array\n    int i = 0;    \/\/ Pointer for leftArr\n    int j = 0;    \/\/ Pointer for rightArr\n    int k = left; \/\/ Pointer for the original array being overwritten\n\n    \/\/ Zip the arrays back together by picking the smaller element\n    while (i &lt; n1 &amp;&amp; j &lt; n2) {\n        if (leftArr&#91;i] &lt;= rightArr&#91;j]) { \/\/ '&lt;=' ensures algorithm stability\n            arr&#91;k] = leftArr&#91;i];\n            i++;\n        } else {\n            arr&#91;k] = rightArr&#91;j];\n            j++;\n        }\n        k++;\n    }\n\n    \/\/ Copy any remaining elements of leftArr, if there are any\n    while (i &lt; n1) {\n        arr&#91;k] = leftArr&#91;i];\n        i++;\n        k++;\n    }\n\n    \/\/ Copy any remaining elements of rightArr, if there are any\n    while (j &lt; n2) {\n        arr&#91;k] = rightArr&#91;j];\n        j++;\n        k++;\n    }\n}\n\n\/\/ 2. The DIVIDE Phase: Recursively splits the array down the middle\nvoid mergeSort(std::vector&lt;int&gt;&amp; arr, int left, int right) {\n    \/\/ Base Case: If the sub-array has 1 or 0 elements, it's already sorted\n    if (left &gt;= right) {\n        return;\n    }\n\n    \/\/ Calculate the midpoint (safely avoiding overflow)\n    int mid = left + (right - left) \/ 2;\n\n    \/\/ Recursively sort the left half\n    mergeSort(arr, left, mid);\n\n    \/\/ Recursively sort the right half\n    mergeSort(arr, mid + 1, right);\n\n    \/\/ Merge the two sorted halves back together\n    merge(arr, left, mid, right);\n}\n\n\/\/ Driver code to test the implementation\nint main() {\n    std::vector&lt;int&gt; arr = {18, 4, 12, 2, 9, 15};\n    \n    std::cout &lt;&lt; \"Original array: \";\n    for (int num : arr) std::cout &lt;&lt; num &lt;&lt; \" \";\n    std::cout &lt;&lt; \"\\n\";\n\n    \/\/ Run Merge Sort on the entire array bounds\n    mergeSort(arr, 0, arr.size() - 1);\n\n    std::cout &lt;&lt; \"Sorted array:   \";\n    for (int num : arr) std::cout &lt;&lt; num &lt;&lt; \" \";\n    std::cout &lt;&lt; \"\\n\";\n\n    return 0;\n}<\/strong><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The array, will be sorted in <strong>Ascending Order<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What will be the change for the array to be sorted in <strong>Descending Order<\/strong>?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You only need to change <strong>one single character<\/strong> inside the helper <code>merge()<\/code> function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\/\/ Change this line (Ascending):\nif (leftArr&#91;i] &lt;= rightArr&#91;j])\n\n\/\/ To this line (Descending):\nif (leftArr&#91;i] &gt;= rightArr&#91;j])<\/strong><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(<strong>Note<\/strong>: Notice that we used <code>&gt;=<\/code> instead of just <code>&gt;<\/code>. Keeping the &#8220;equal to&#8221; part ensures that the algorithm remains <strong>stable<\/strong>\u2014meaning elements with duplicate values will still preserve their original relative order even when sorting backwards!)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How does Merge Sort stands out from other algorithms?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Merge Sort:<\/strong> Follows a structural <strong>divide-and-conquer<\/strong> approach. It recursively splits an array directly down the middle until every element stands alone as a 1-element sublist, then systematically zips (merges) those sorted sublists back together.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike <strong>Quick Sort:<\/strong> Another divide-and-conquer method, but instead of splitting down the center, it picks a <strong>pivot element<\/strong> and partitions the data so smaller items go left and larger items go right. <strong>Selection Sort:<\/strong> Operates on a raw scanning approach, repeatedly walking through the unsorted section of the array to pick out the absolute minimum element and swapping it to the front. <strong>Insertion Sort:<\/strong> Loops through the data sequentially, pulling one element at a time and shifting previous elements over to drop it into its correct position.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Merge Sort\u2019s <\/strong>biggest differentiator is its memory footprint. It is an <strong>out-of-place<\/strong> algorithm. Unlike <strong>Selection Sort <\/strong>or <strong>Quick Sort<\/strong>, which shuffle elements around directly inside the original array bounds, <strong>Merge Sort <\/strong>requires external helper arrays to safely zip sorted subsets together without erasing data. This gives it a linear extra memory requirement of <strong>O(n)<\/strong>.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Many algorithms depend on the randomness of the data layout. For example, <strong>Quick Sort <\/strong>can degrade to a slow <strong><math data-latex=\"O(n^2)\"><semantics><mrow><mi>O<\/mi><mo form=\"prefix\" stretchy=\"false\">(<\/mo><msup><mi>n<\/mi><mn>2<\/mn><\/msup><mo form=\"postfix\" stretchy=\"false\">)<\/mo><\/mrow><annotation encoding=\"application\/x-tex\">O(n^2)<\/annotation><\/semantics><\/math><\/strong> if it repeatedly picks a poor pivot on a pre-sorted array. <strong>Merge Sort <\/strong>completely ignores how messy or organized your initial data is. Because it splits arrays mathematically down the absolute center every time, it guarantees a rock-solid <strong>O(<\/strong><math data-latex=\"n logn\"><semantics><mrow><mi>n<\/mi><mi>l<\/mi><mi>o<\/mi><mi>g<\/mi><mi>n<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">n logn<\/annotation><\/semantics><\/math><strong>)<\/strong> time complexity across its best, average, and worst cases.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Where Merge Sort Is Highly Helpful?<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Sorting Massive Datasets<\/strong><\/li>\n\n\n\n<li><strong>Sorting Linked Lists<\/strong><\/li>\n\n\n\n<li><strong>When Stability is Mandatory<\/strong><\/li>\n\n\n\n<li><strong>External Sorting (Files Too Big for RAM)<\/strong><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Where Merge Sort Is Not Helpful<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Memory-Constrained Systems<\/strong><\/li>\n\n\n\n<li><strong>Highly Speed-Critical Array Sorting in RAM<\/strong><\/li>\n\n\n\n<li><strong>Small Datasets<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In algorithmic analysis, <strong>Merge Sort<\/strong> represents the definitive benchmark for stable, deterministic performance. By decoupling its execution steps from the initial state of the input array, it eliminates the worst-case performance degradation common to non-balanced algorithms, enforcing a strict structural bound of <strong>O(n log n)<\/strong> time complexity across best, average, and worst-case scenarios.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the real world of software engineering, there is no single &#8220;best&#8221; sorting algorithm. <strong>Selection Sort <\/strong>is fantastic when you want zero memory overhead on tiny lists. <strong>Quick Sort <\/strong>is the king of raw speed inside system RAM. But when you need a highly stable, completely dependable algorithm that can tame massive datasets and linked lists without ever breaking its pace, <strong>Merge Sort<\/strong> remains one of the most brilliant and enduring tools in a programmer&#8217;s toolkit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merge Sort Explained: Logic, Code, and Complexity One of the most effecient way of sorting is MERGE SORT. As we [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[66,49,50],"tags":[67,65,60,64,69,70,54,68],"class_list":["post-149","post","type-post","status-publish","format-standard","hentry","category-algorithms","category-data-structures","category-sorting","tag-algorithm","tag-c","tag-data-structures","tag-learning-to-code","tag-merge-sort","tag-progaramming","tag-sorting","tag-sorting-technique"],"_links":{"self":[{"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/posts\/149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/comments?post=149"}],"version-history":[{"count":4,"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/posts\/149\/revisions"}],"predecessor-version":[{"id":176,"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/posts\/149\/revisions\/176"}],"wp:attachment":[{"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/media?parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/categories?post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.csfree.org\/index.php\/wp-json\/wp\/v2\/tags?post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}