{"id":2929,"date":"2021-02-12T17:00:16","date_gmt":"2021-02-12T17:00:16","guid":{"rendered":"https:\/\/www.dpscomputing.com\/blog\/?p=2929"},"modified":"2021-03-01T21:22:03","modified_gmt":"2021-03-01T21:22:03","slug":"what-is-an-algorithm-and-why-are-they-useful","status":"publish","type":"post","link":"https:\/\/www.dpscomputing.com\/blog\/2021\/02\/12\/what-is-an-algorithm-and-why-are-they-useful\/","title":{"rendered":"What is an algorithm and why are they useful?"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2930\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2021\/02\/12\/what-is-an-algorithm-and-why-are-they-useful\/rubiks-cube-2827179_640\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640.jpg\" data-orig-size=\"640,423\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;10&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;NIKON D5100&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;29&quot;,&quot;iso&quot;:&quot;100&quot;,&quot;shutter_speed&quot;:&quot;1&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"rubiks-cube-2827179_640\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640-300x198.jpg\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640.jpg\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640.jpg\" alt=\"\" class=\"wp-image-2930\" width=\"320\" height=\"212\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640.jpg 640w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640-300x198.jpg 300w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640-150x99.jpg 150w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/figure><\/div>\n\n\n\n<p>Algorithms.  They&#8217;re all around us.  You might not have noticed but we are literally surrounded by them!  Not only that, whether you realise or not you will have created and followed many algorithms just over the past few days!<\/p>\n\n\n\n<p>Planned your route through the supermarket for the bits you need?  Algorithm.  <\/p>\n\n\n\n<p>Made a (virtual) commute into work?  Algorithm.  <\/p>\n\n\n\n<p>Cooked a meal following a recipe?  Algorithm.  <\/p>\n\n\n\n<p>Built some new Ikea furniture?  Algorithm.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">So what exactly is an algorithm?<\/h2>\n\n\n\n<p>Algorithms are often used and cited in computing, but they are all around us.  <\/p>\n\n\n\n<p>Put simply, an algorithm is a list of rules to follow in order to solve a problem.  Rules can mean steps and a problem can be something as simple as getting ready for work and school.  It doesn&#8217;t have to be overly complex, although of course could be.  <\/p>\n\n\n\n<p>An algorithm could be anything from how to prepare your breakfast in the morning, which you likely do on auto-pilot through to manufacturing a vaccine for COVID-19.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Give me an example of an algorithm.<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2931\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2021\/02\/12\/what-is-an-algorithm-and-why-are-they-useful\/checklist-1919292_640\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/checklist-1919292_640.jpg\" data-orig-size=\"546,640\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"checklist-1919292_640\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/checklist-1919292_640-256x300.jpg\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/checklist-1919292_640.jpg\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/checklist-1919292_640.jpg\" alt=\"\" class=\"wp-image-2931\" width=\"273\" height=\"320\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/checklist-1919292_640.jpg 546w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/checklist-1919292_640-256x300.jpg 256w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/checklist-1919292_640-128x150.jpg 128w\" sizes=\"auto, (max-width: 273px) 100vw, 273px\" \/><\/figure><\/div>\n\n\n\n<p>If we start at the more relatable and hopefully simpler end of the spectrum, let&#8217;s look at preparing breakfast in the morning.  The algorithm for this could look like:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Get a bowl.  <\/li><li>Get the cereal packet out of the cupboard.  <\/li><li>Pour a portion of cereal into the bowl.  <\/li><li>Get the milk out of the fridge.  <\/li><li>Pour a small amount of milk over the cereal in the bowl.  <\/li><li>Get a spoon from the cutlery drawer.  <\/li><li>Place the cereal packet back in the cupboard.  <\/li><li>Sit down and enjoy the cereal!<\/li><li>Place the empty bowl and spoon into the dishwasher.  <\/li><\/ol>\n\n\n\n<p>You likely do all of this on auto pilot because of so much practice!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Could we add more steps?<\/h2>\n\n\n\n<p>Of course.  There&#8217;s many &#8216;right&#8217; ways to do things.  The important thing to consider is, if I follow the steps, will I solve the problem or complete the task.  If it&#8217;s a yes, we&#8217;ve got a good algorithm.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Being specific.  <\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2932\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2021\/02\/12\/what-is-an-algorithm-and-why-are-they-useful\/to-do-2607082_640\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/to-do-2607082_640.jpg\" data-orig-size=\"640,426\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"to-do-2607082_640\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/to-do-2607082_640-300x200.jpg\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/to-do-2607082_640.jpg\" tabindex=\"0\" role=\"button\" src=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/to-do-2607082_640.jpg\" alt=\"\" class=\"wp-image-2932\" width=\"320\" height=\"213\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/to-do-2607082_640.jpg 640w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/to-do-2607082_640-300x200.jpg 300w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/to-do-2607082_640-150x100.jpg 150w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><figcaption>Could do with a little more detail&#8230;<\/figcaption><\/figure><\/div>\n\n\n\n<p>The success of an algorithm is usually down to it&#8217;s specificity.  If you follow the steps above for your own breakfast routine, you&#8217;ll likely get it right through knowledge and experience.  However, the real test is if you give it to someone else to try!<\/p>\n\n\n\n<p>So, in the example above, have I been very specific?  In some ways I have, but in others not so much.  How much milk should I pour over my cereal?  How much is a small amount?  That&#8217;s probably going to be subjective depending on the person.  It might even be subjective depending on the cereal.  I like to drench Weetabix but I&#8217;ll accept less milk on my Cheerios!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Improvements<\/h2>\n\n\n\n<p>If I was improving the algorithm, I might make the following changes:<\/p>\n\n\n\n<ol class=\"wp-block-list\" id=\"block-988a2e94-3753-494d-874c-b3ebe1e02130\"><li>Get a bowl.<\/li><li>Get the cereal packet out of the cupboard <em><strong>next to the oven<\/strong><\/em>.<\/li><li>Pour a <strong><em>25g<\/em><\/strong> portion of cereal into the bowl.<\/li><li>Get the milk out of the fridge.<\/li><li>Pour <strong><em>5ml<\/em><\/strong> of milk over the cereal in the bowl.<\/li><li>Get a <b><i>tablespoon<\/i><\/b> from the cutlery drawer.<\/li><li>Place the cereal packet back in the cupboard <strong><em>next to the oven<\/em><\/strong>.<\/li><li>Sit down and enjoy the cereal!<\/li><li><strong><em>Once finished<\/em><\/strong>, place the empty bowl and spoon into the dishwasher.<\/li><\/ol>\n\n\n\n<p>Now this algorithm looks more detailed and therefore we&#8217;ve enhanced it so it&#8217;s more likely to be successfully followed by someone else.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">So, when do I stop improving?<\/h2>\n\n\n\n<p>The short answer is, never.  Through testing of algorithms and interpretation by others we often find unexpected circumstances that may affect completion of the problem or the efficiency in reaching the end goal.  Maintaining an algorithm is a cyclical process.  <\/p>\n\n\n\n<p>Have any questions on algorithms?  Maybe you have an example yourself?  Drop them in the comments below!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Algorithms. They&#8217;re all around us. You might not have noticed but we are literally surrounded by them! Not only that, whether you realise or not you will have created and followed many algorithms just&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2930,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[55],"tags":[2760,2763,2759,2764,2762,2765,2761,2766],"class_list":["post-2929","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","tag-algorithm","tag-algorithm-example","tag-algorithms","tag-breakfast-algorithms","tag-everyday-algorithms","tag-improving-an-algorithm","tag-what-is-an-algorithm","tag-what-makes-a-good-algorithm"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2021\/02\/rubiks-cube-2827179_640.jpg","jetpack_shortlink":"https:\/\/wp.me\/p3nsfA-Lf","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/comments?post=2929"}],"version-history":[{"count":2,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2929\/revisions"}],"predecessor-version":[{"id":2989,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/2929\/revisions\/2989"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/media\/2930"}],"wp:attachment":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/media?parent=2929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/categories?post=2929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/tags?post=2929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}