{"id":541,"date":"2023-03-23T07:34:19","date_gmt":"2023-03-23T07:34:19","guid":{"rendered":"http:\/\/learnlearn.uk\/ibcs\/?page_id=541"},"modified":"2023-06-09T13:03:07","modified_gmt":"2023-06-09T13:03:07","slug":"bubble-sort","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/","title":{"rendered":"Bubble Sort"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Introduction<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Bubble Sort<\/h3>\n<p><span style=\"color: #0000ff;\">Time Complexity:\u00a0O(n\u00b2) &#8211; Space Complexity: O(1)<\/span><\/p>\n<p>Pretty much the worst sorting algorithm ever, mostly just used in teaching as a comparison tool. There are <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bubble_sort\">almost <\/a>no legitimate use cases where it is the most efficient algorithm.<\/p>\n<p>The bubble sort algorithm works by sorting through the array in pairs. It starts at the left of the array and inspects the first two items. If the items are in the wrong order they are swapped around. The algorithm then carries on with the next pair along and so forth. When it reaches the end of the array it goes back to the beginning of the array and starts again. If it completes a full pass of the array without swapping any items it knows that the array is sorted.<\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/File:Bubble-sort-example-300px.gif\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-29 aligncenter\" src=\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-content\/uploads\/sites\/27\/2023\/06\/bubble-sort.gif\" alt=\"Bubble sort animation. Credit - Wikipedia \" width=\"300\" height=\"180\" \/><\/a><\/p>\n\n<\/div><h2 class=\"tabtitle\">Tutorial Video<\/h2>\n<div class=\"tabcontent\">\n\n<p><strong>Bubble Sort Python Tutorial<\/strong><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/sRioelAlIaY\" width=\"900\" height=\"600\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\" data-mce-fragment=\"1\"><\/iframe><\/p>\n\n<\/div><h2 class=\"tabtitle\">Demonstration<\/h2>\n<div class=\"tabcontent\">\n\n<h4>Bubble Sort Demonstration<br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/scratch.mit.edu\/projects\/444092744\/embed\" width=\"900\" height=\"600\" frameborder=\"0\" scrolling=\"no\" allowfullscreen=\"allowfullscreen\" data-mce-fragment=\"1\"><\/iframe><\/h4>\n\n<\/div><h2 class=\"tabtitle\">Python Code<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Python Code<\/h3>\n<p><iframe loading=\"lazy\" src=\"https:\/\/trinket.io\/embed\/python\/32bc633113\" width=\"100%\" height=\"600\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" allowfullscreen=\"allowfullscreen\" data-mce-fragment=\"1\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Resources<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Resources<\/h3>\n<p><a href=\"https:\/\/www.aicurriculum.co.uk\/resources\/52eef924-4d20-4b23-80b3-9ad71221676f\">Bubble Sort Flashcards &amp; Quizzes<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bubble Sort Time Complexity:\u00a0O(n\u00b2) &#8211; Space Complexity: O(1) Pretty much the worst sorting algorithm ever, mostly just used in teaching as a comparison tool. There are almost no legitimate use cases where it is the most efficient algorithm. The bubble sort algorithm works by sorting through the array in pairs. It starts at the left&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Bubble 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>Bubble 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\/bubble-sort\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bubble Sort - IB Computer Science\" \/>\n<meta property=\"og:description\" content=\"Bubble Sort Time Complexity:\u00a0O(n\u00b2) &#8211; Space Complexity: O(1) Pretty much the worst sorting algorithm ever, mostly just used in teaching as a comparison tool. There are almost no legitimate use cases where it is the most efficient algorithm. The bubble sort algorithm works by sorting through the array in pairs. It starts at the left&hellip;&nbsp;Read More &raquo;Bubble Sort\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/\" \/>\n<meta property=\"og:site_name\" content=\"IB Computer Science\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-09T13:03:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-content\/uploads\/sites\/27\/2023\/06\/bubble-sort.gif\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/\",\"url\":\"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/\",\"name\":\"Bubble Sort - IB Computer Science\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/#website\"},\"datePublished\":\"2023-03-23T07:34:19+00:00\",\"dateModified\":\"2023-06-09T13:03:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"IB Computer Science\",\"item\":\"https:\/\/learnlearn.uk\/ibcs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bubble 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":"Bubble 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\/bubble-sort\/","og_locale":"en_GB","og_type":"article","og_title":"Bubble Sort - IB Computer Science","og_description":"Bubble Sort Time Complexity:\u00a0O(n\u00b2) &#8211; Space Complexity: O(1) Pretty much the worst sorting algorithm ever, mostly just used in teaching as a comparison tool. There are almost no legitimate use cases where it is the most efficient algorithm. The bubble sort algorithm works by sorting through the array in pairs. It starts at the left&hellip;&nbsp;Read More &raquo;Bubble Sort","og_url":"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/","og_site_name":"IB Computer Science","article_modified_time":"2023-06-09T13:03:07+00:00","og_image":[{"url":"https:\/\/learnlearn.uk\/edexcel-igcse-computer-science\/wp-content\/uploads\/sites\/27\/2023\/06\/bubble-sort.gif"}],"twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/","url":"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/","name":"Bubble Sort - IB Computer Science","isPartOf":{"@id":"https:\/\/learnlearn.uk\/ibcs\/#website"},"datePublished":"2023-03-23T07:34:19+00:00","dateModified":"2023-06-09T13:03:07+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/ibcs\/bubble-sort\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"IB Computer Science","item":"https:\/\/learnlearn.uk\/ibcs\/"},{"@type":"ListItem","position":2,"name":"Bubble 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":"Bubble Sort Time Complexity:\u00a0O(n\u00b2) &#8211; Space Complexity: O(1) Pretty much the worst sorting algorithm ever, mostly just used in teaching as a comparison tool. There are almost no legitimate use cases where it is the most efficient algorithm. The bubble sort algorithm works by sorting through the array in pairs. It starts at the left&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/541"}],"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=541"}],"version-history":[{"count":2,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/541\/revisions"}],"predecessor-version":[{"id":670,"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/pages\/541\/revisions\/670"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/ibcs\/wp-json\/wp\/v2\/media?parent=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}