{"id":404,"date":"2018-01-22T14:42:37","date_gmt":"2018-01-22T14:42:37","guid":{"rendered":"http:\/\/learnlearn.uk\/gcsecs\/?page_id=404"},"modified":"2020-11-09T12:33:20","modified_gmt":"2020-11-09T12:33:20","slug":"sorting-algorithms","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/","title":{"rendered":"Sorting algorithms"},"content":{"rendered":"<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">Starter<\/h2>\n<div class=\"tabcontent\">\n\n<p>Have a go at this sorting game. How quickly can you sort all the letters just by clicking on letters to swap?<\/p>\n<p><iframe loading=\"lazy\" src=\"\/\/scratch.mit.edu\/projects\/embed\/138967507\/?autostart=false\" width=\"800\" height=\"600\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n<\/div><h2 class=\"tabtitle\">Introduction<\/h2>\n<div class=\"tabcontent\">\n\n<div class=\"arconix-column-two-thirds\">\n<h3>Sorting algorithms &#8211; Why do we need them?<\/h3>\n<p>One of the most important jobs a computer performs for us is sorting of data. Without sorted data our computer systems would be much harder to use.<\/p>\n<p>Imagine:<\/p>\n<div class=\"arconix-list\" data-arconix-icon=\"fa-chevron-circle-right\" data-arconix-color=\"black\">\n<ul>\n<li>trying to read through all your emails if they were in a random date order.<\/li>\n<li>finding\u00a0a friend&#8217;s telephone number if all you contacts were in a random order.<\/li>\n<li>loading an app from your apps list if they were all jumbled up.<\/li>\n<\/ul>\n<\/div>\n<p>There are many different ordering systems we can use, common ones include:<\/p>\n<div class=\"arconix-list\" data-arconix-icon=\"fa-chevron-circle-right\" data-arconix-color=\"black\">\n<ul>\n<li>alphabetical order<\/li>\n<li>numerical order<\/li>\n<li>date order<\/li>\n<li>size order<\/li>\n<\/ul>\n<\/div>\n<p><strong>Different sorting algorithms<\/strong><\/p>\n<p>There are many different algorithms(methods) for sorting \u00a0lists of things. In the last task some people will have sorted the letters the fastest (most time efficient) or with the least number of swap (most effort efficient). Have a chat with the person next to about how they sorted out the list. What technique did they use? Whose algorithm was the most time \/ effort efficient?<\/p>\n<p>In computer science we have many different sorting techniques, some are most efficient than others, some are simpler than others. Today we will be looking at:<\/p>\n<div class=\"arconix-list\" data-arconix-icon=\"fa-chevron-circle-right\" data-arconix-color=\"black\">\n<ul>\n<li>Insertion Sort<\/li>\n<li>Bubble Sort<\/li>\n<li>Selection Sort<\/li>\n<\/ul>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"arconix-column-one-third\">\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-12\" src=\"https:\/\/learnlearn.uk\/algorithms\/wp-content\/uploads\/sites\/12\/2017\/01\/sort-271x300.png\" alt=\"sort\" width=\"271\" height=\"300\" \/><\/p>\n<\/div>\n\n<\/div><h2 class=\"tabtitle\">Insertion Sort<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Insertion Sort<\/h3>\n<p>With the insertion sort algorithm, you go through each item in the list in turn and move to its correct position in the list. The algorithm is slow but simple.<\/p>\n<p>Insertion Sort Tutorial<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/jRsm6FmHp7M\" width=\"960\" height=\"600\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><a href=\"https:\/\/gist.github.com\/richardbwest\/ece6d6e0c624f41fc3009e19633bf411\">Insertion Sort Python Code<\/a><\/p>\n<p><a href=\"https:\/\/gist.github.com\/richardbwest\/10781a339c51006658b50638f7e09eb1\">Insertion Sort Python Demo code<\/a><\/p>\n\n<\/div><h2 class=\"tabtitle\">Bubble Sort<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Bubble Sort<\/h3>\n<p><span style=\"color: #0000ff;\"><em>AS &amp; A Level \u2013 You are required to know how it works and be able to write Code \/ Pseudocode for the algorithm<\/em><\/span><\/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><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\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\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\"><\/iframe><\/h4>\n\n<\/div><h2 class=\"tabtitle\">Merge Sort<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Merge Sort<\/h3>\n<div class=\"nv-iframe-embed\">\n<div class=\"container-lazyload preview-lazyload container-youtube js-lazyload--not-loaded\"><a href=\"https:\/\/www.youtube.com\/watch?v=Nso25TkBsYI\" class=\"lazy-load-youtube preview-lazyload preview-youtube\" data-video-title=\"Python: MergeSort algorithm explained\" title=\"Play video &quot;Python: MergeSort algorithm explained&quot;\">https:\/\/www.youtube.com\/watch?v=Nso25TkBsYI<\/a><noscript>Video can&#8217;t be loaded because JavaScript is disabled: <a href=\"https:\/\/www.youtube.com\/watch?v=Nso25TkBsYI\" title=\"Python: MergeSort algorithm explained\">Python: MergeSort algorithm explained (https:\/\/www.youtube.com\/watch?v=Nso25TkBsYI)<\/a><\/noscript><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n\n<\/div><h2 class=\"tabtitle\">Activity 1<\/h2>\n<div class=\"tabcontent\">\n\n<h3>Activity 1 &#8211; People Sorter<\/h3>\n<p>Replicate the class activity for each sorting algorithm (this can be done after introducing each sorting algorithm.<\/p>\n<p>Best splitting the class in to groups of 15 or less (otherwise the sorting will take a rather long time!<\/p>\n<p>Alternative Activity &#8211; Have a go at sorting letters using the scratch game below<\/p>\n<a href='https:\/\/scratch.mit.edu\/projects\/138977648\/#fullscreen' class='arconix-button arconix-button-medium arconix-button-gray' target=\"_blank\" >Scratch Practise<\/a>\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:\/\/docs.google.com\/spreadsheets\/d\/1Wux7Vtl-HKcElCBHHSI9guUKwsF13tYdM3DKwSHlrF8\/edit?usp=sharing\">Keywords and Definitions<\/a><\/p>\n<p><a href=\"https:\/\/drive.google.com\/file\/d\/16cTb1NvVU3SbDModFYR1uCfAmK3floMD\/view?usp=sharing\">Algorithm Unit Flashcards<\/a><\/p>\n<p>&nbsp;<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Have a go at this sorting game. How quickly can you sort all the letters just by clicking on letters to swap? Insertion Sort With the insertion sort algorithm, you go through each item in the list in turn and move to its correct position in the list. The algorithm is slow but simple. Insertion&hellip;&nbsp;<a href=\"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Sorting algorithms<\/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":"","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>Sorting algorithms - GCSE Computer Science Theory<\/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\/gcsecs\/sorting-algorithms\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sorting algorithms - GCSE Computer Science Theory\" \/>\n<meta property=\"og:description\" content=\"Have a go at this sorting game. How quickly can you sort all the letters just by clicking on letters to swap? Insertion Sort With the insertion sort algorithm, you go through each item in the list in turn and move to its correct position in the list. The algorithm is slow but simple. Insertion&hellip;&nbsp;Read More &raquo;Sorting algorithms\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/\" \/>\n<meta property=\"og:site_name\" content=\"GCSE Computer Science Theory\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-09T12:33:20+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/learnlearn.uk\/algorithms\/wp-content\/uploads\/sites\/12\/2017\/01\/sort-271x300.png\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/\",\"url\":\"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/\",\"name\":\"Sorting algorithms - GCSE Computer Science Theory\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/#website\"},\"datePublished\":\"2018-01-22T14:42:37+00:00\",\"dateModified\":\"2020-11-09T12:33:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"OCR GCSE Computer Science Home\",\"item\":\"https:\/\/learnlearn.uk\/gcsecs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sorting algorithms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/#website\",\"url\":\"https:\/\/learnlearn.uk\/gcsecs\/\",\"name\":\"GCSE Computer Science Theory\",\"description\":\"Just another My Blog site\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/gcsecs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/#organization\",\"name\":\"GCSE Computer Science Theory\",\"url\":\"https:\/\/learnlearn.uk\/gcsecs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/gcsecs\/wp-content\/uploads\/sites\/8\/2019\/02\/LearnLearnLogowhite.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/gcsecs\/wp-content\/uploads\/sites\/8\/2019\/02\/LearnLearnLogowhite.png\",\"width\":710,\"height\":98,\"caption\":\"GCSE Computer Science Theory\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/gcsecs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sorting algorithms - GCSE Computer Science Theory","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\/gcsecs\/sorting-algorithms\/","og_locale":"en_GB","og_type":"article","og_title":"Sorting algorithms - GCSE Computer Science Theory","og_description":"Have a go at this sorting game. How quickly can you sort all the letters just by clicking on letters to swap? Insertion Sort With the insertion sort algorithm, you go through each item in the list in turn and move to its correct position in the list. The algorithm is slow but simple. Insertion&hellip;&nbsp;Read More &raquo;Sorting algorithms","og_url":"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/","og_site_name":"GCSE Computer Science Theory","article_modified_time":"2020-11-09T12:33:20+00:00","og_image":[{"url":"http:\/\/learnlearn.uk\/algorithms\/wp-content\/uploads\/sites\/12\/2017\/01\/sort-271x300.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/","url":"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/","name":"Sorting algorithms - GCSE Computer Science Theory","isPartOf":{"@id":"https:\/\/learnlearn.uk\/gcsecs\/#website"},"datePublished":"2018-01-22T14:42:37+00:00","dateModified":"2020-11-09T12:33:20+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/gcsecs\/sorting-algorithms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"OCR GCSE Computer Science Home","item":"https:\/\/learnlearn.uk\/gcsecs\/"},{"@type":"ListItem","position":2,"name":"Sorting algorithms"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/gcsecs\/#website","url":"https:\/\/learnlearn.uk\/gcsecs\/","name":"GCSE Computer Science Theory","description":"Just another My Blog site","publisher":{"@id":"https:\/\/learnlearn.uk\/gcsecs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/gcsecs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/gcsecs\/#organization","name":"GCSE Computer Science Theory","url":"https:\/\/learnlearn.uk\/gcsecs\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/gcsecs\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/gcsecs\/wp-content\/uploads\/sites\/8\/2019\/02\/LearnLearnLogowhite.png","contentUrl":"https:\/\/learnlearn.uk\/gcsecs\/wp-content\/uploads\/sites\/8\/2019\/02\/LearnLearnLogowhite.png","width":710,"height":98,"caption":"GCSE Computer Science Theory"},"image":{"@id":"https:\/\/learnlearn.uk\/gcsecs\/#\/schema\/logo\/image\/"}}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/gcsecs\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":"Have a go at this sorting game. How quickly can you sort all the letters just by clicking on letters to swap? Insertion Sort With the insertion sort algorithm, you go through each item in the list in turn and move to its correct position in the list. The algorithm is slow but simple. Insertion&hellip;&nbsp;Read&hellip;","_links":{"self":[{"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/pages\/404"}],"collection":[{"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/comments?post=404"}],"version-history":[{"count":9,"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/pages\/404\/revisions"}],"predecessor-version":[{"id":967,"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/pages\/404\/revisions\/967"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/gcsecs\/wp-json\/wp\/v2\/media?parent=404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}