{"id":543,"date":"2023-03-23T07:36:03","date_gmt":"2023-03-23T07:36:03","guid":{"rendered":"http:\/\/learnlearn.uk\/ibcs\/?page_id=543"},"modified":"2025-04-05T11:01:21","modified_gmt":"2025-04-05T11:01:21","slug":"merge-sort","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/","title":{"rendered":"Merge Sort"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Introduction to Merge Sort<\/h2>\n<div class=\"tabcontent\">\n\n<h2>Introduction to Merge Sort<\/h2>\n<p>Merge Sort is a popular sorting algorithm that follows the\u00a0<b>divide and conquer<\/b>\u00a0approach. The algorithm works by breaking down the list into smaller sub-lists and sorting them individually.<\/p>\n<p>These sorted sub-lists are then merged back together to obtain the final sorted list.<\/p>\n<p>&nbsp;<\/p>\n<h3 class=\"\">Time &amp; Space Complexity<\/h3>\n<ul>\n<li>Merge sort is a divide and conquer algorithm, it has a logarithmic time complexity of\u00a0\u00a0O(n log n)<\/li>\n<li>Merge sort&#8217;s space complexity is\u00a0O(n)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Steps of Merge Sort<\/h2>\n<div class=\"tabcontent\">\n\n<h2>Steps of Merge Sort<\/h2>\n<ol>\n<li>Divide the unsorted list into smaller sub-lists until each sub-list contains only one element.<\/li>\n<li>Repeatedly merge adjacent sub-lists to produce new sorted sub-lists until there is only one sub-list remaining. This is done by comparing the elements of the sub-lists and merging them in the correct order.<\/li>\n<li>The final sorted list is obtained when all sub-lists are merged.<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/revise.learnlearn.uk\/django-summernote\/2023-11-02\/24fe73bd-64c0-4b94-9123-4fd196d2e493.gif\" \/><\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Merge_sort#\/media\/File:Merge-sort-example-300px.gif\" target=\"_blank\" rel=\"noopener\">Source: Wikipedia<\/a><\/p>\n\n<\/div><h2 class=\"tabtitle\">Advantages of Merge Sort<\/h2>\n<div class=\"tabcontent\">\n\n<h2>Advantages of Merge Sort<\/h2>\n<ul>\n<li>Merge Sort guarantees a stable sort, which means that the order of equal elements is preserved.<\/li>\n<li>It performs well on large lists and has a time complexity of O(n log n), where n is the number of elements in the list.<\/li>\n<\/ul>\n\n<\/div><h2 class=\"tabtitle\">Disadvantages of Merge Sort:<\/h2>\n<div class=\"tabcontent\">\n\n<h2>Disadvantages of Merge Sort:<\/h2>\n<ul>\n<li>It is not an in-place sorting algorithm, meaning it needs extra storage proportional to the size of the input list.<\/li>\n<li>Because it is usually implemented using recursion it can be difficult for beginner programmers to implement and understand.<\/li>\n<\/ul>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Merge Sort Merge Sort is a popular sorting algorithm that follows the\u00a0divide and conquer\u00a0approach. The algorithm works by breaking down the list into smaller sub-lists and sorting them individually. These sorted sub-lists are then merged back together to obtain the final sorted list. &nbsp; Time &amp; Space Complexity Merge sort is a divide&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Merge Sort<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"off","neve_meta_content_width":70,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Merge Sort - IB Computer Science<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Merge Sort - IB Computer Science\" \/>\n<meta property=\"og:description\" content=\"Introduction to Merge Sort Merge Sort is a popular sorting algorithm that follows the\u00a0divide and conquer\u00a0approach. The algorithm works by breaking down the list into smaller sub-lists and sorting them individually. These sorted sub-lists are then merged back together to obtain the final sorted list. &nbsp; Time &amp; Space Complexity Merge sort is a divide&hellip;&nbsp;Read More &raquo;Merge Sort\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/\" \/>\n<meta property=\"og:site_name\" content=\"IB Computer Science\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-05T11:01:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/revise.learnlearn.uk\/django-summernote\/2023-11-02\/24fe73bd-64c0-4b94-9123-4fd196d2e493.gif\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/\",\"name\":\"Merge Sort - IB Computer Science\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#website\"},\"datePublished\":\"2023-03-23T07:36:03+00:00\",\"dateModified\":\"2025-04-05T11:01:21+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"IB Computer Science\",\"item\":\"https:\/\/learnlearn.uk\/ibcs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Merge Sort\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#website\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/\",\"name\":\"IB Computer Science\",\"description\":\"- learnlearn..uk\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/ibcs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#organization\",\"name\":\"IB Computer Science\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png\",\"width\":300,\"height\":41,\"caption\":\"IB Computer Science\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Merge Sort - IB Computer Science","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:\/\/learnlearn.uk\/ibcs\/merge-sort\/","og_locale":"en_GB","og_type":"article","og_title":"Merge Sort - IB Computer Science","og_description":"Introduction to Merge Sort Merge Sort is a popular sorting algorithm that follows the\u00a0divide and conquer\u00a0approach. The algorithm works by breaking down the list into smaller sub-lists and sorting them individually. These sorted sub-lists are then merged back together to obtain the final sorted list. &nbsp; Time &amp; Space Complexity Merge sort is a divide&hellip;&nbsp;Read More &raquo;Merge Sort","og_url":"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/","og_site_name":"IB Computer Science","article_modified_time":"2025-04-05T11:01:21+00:00","og_image":[{"url":"https:\/\/revise.learnlearn.uk\/django-summernote\/2023-11-02\/24fe73bd-64c0-4b94-9123-4fd196d2e493.gif"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/","url":"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/","name":"Merge Sort - IB Computer Science","isPartOf":{"@id":"https:\/\/learnlearn.uk\/ibcs\/#website"},"datePublished":"2023-03-23T07:36:03+00:00","dateModified":"2025-04-05T11:01:21+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/ibcs\/merge-sort\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/ibcs\/merge-sort\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"IB Computer Science","item":"https:\/\/learnlearn.uk\/ibcs\/"},{"@type":"ListItem","position":2,"name":"Merge Sort"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/ibcs\/#website","url":"https:\/\/learnlearn.uk\/ibcs\/","name":"IB Computer Science","description":"- learnlearn..uk","publisher":{"@id":"https:\/\/learnlearn.uk\/ibcs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/ibcs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/ibcs\/#organization","name":"IB Computer Science","url":"https:\/\/learnlearn.uk\/ibcs\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png","contentUrl":"https:\/\/learnlearn.uk\/ibcs\/wp-content\/uploads\/sites\/25\/2022\/09\/LearnLearnLogowhite-300x41.png","width":300,"height":41,"caption":"IB Computer Science"},"image":{"@id":"https:\/\/learnlearn.uk\/ibcs\/#\/schema\/logo\/image\/"}}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/ibcs\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":"Introduction to Merge Sort Merge Sort is a popular sorting algorithm that follows the\u00a0divide and conquer\u00a0approach. The algorithm works by breaking down the list into smaller sub-lists and sorting them individually. These sorted sub-lists are then merged back together to obtain the final sorted list. &nbsp; Time &amp; Space Complexity Merge sort is a divide&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/543"}],"collection":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":2,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/543\/revisions"}],"predecessor-version":[{"id":1198,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/543\/revisions\/1198"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/media?parent=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}