{"id":265,"date":"2022-05-24T17:34:00","date_gmt":"2022-05-24T16:34:00","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/?page_id=265"},"modified":"2022-05-24T18:48:27","modified_gmt":"2022-05-24T17:48:27","slug":"standard-algorithms","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/standard-algorithms\/","title":{"rendered":"Finding Maximum and Minimum"},"content":{"rendered":"<p>Because of the regularity with which these processes occur in different problems, they are known as <strong>standard algorithms<\/strong>.\u00a0 Each of the following 5 algorithms covered on the next few pages would typically be implemented as a <strong>function<\/strong> or <strong>procedure<\/strong>.<\/p>\n<h2 style=\"color: red\">Input Validation (Nat 5 algorithm)<\/h2>\n<p>Input validation is used to ensure that the user enters only data that is acceptable i.e. in a suitable format and within the limits of the data required for processing.<\/p>\n<p><strong style=\"color: red\">Example in Pseudocode<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-269\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24174322\/Screenshot-2022-05-24-174311-300x85.png\" alt=\"\" width=\"445\" height=\"126\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24174322\/Screenshot-2022-05-24-174311-300x85.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24174322\/Screenshot-2022-05-24-174311-768x219.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24174322\/Screenshot-2022-05-24-174311-624x178.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24174322\/Screenshot-2022-05-24-174311.png 970w\" sizes=\"auto, (max-width: 445px) 100vw, 445px\" \/><\/p>\n<p><strong style=\"color: red\">Example in Python<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-270\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24175039\/Screenshot-2022-05-24-175026-300x58.png\" alt=\"\" width=\"909\" height=\"176\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24175039\/Screenshot-2022-05-24-175026-300x58.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24175039\/Screenshot-2022-05-24-175026-1024x199.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24175039\/Screenshot-2022-05-24-175026-768x149.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24175039\/Screenshot-2022-05-24-175026-624x121.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24175039\/Screenshot-2022-05-24-175026.png 1260w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/p>\n<h2 style=\"color: red\">Finding Maximum and Finding Minimum<\/h2>\n<p>These algorithms are most typically used when processing a list of data items in an <strong>array<\/strong>, for example finding the highest and lowest temperatures in some weather data or the fastest finisher in a cycling event from timing chip data recorded.<\/p>\n<p>The algorithms are obviously very similar since they use the same process.<\/p>\n<p><strong style=\"color: red\">Example in Pseudocode &#8211; Finding Maximum<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-286\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184128\/Screenshot-2022-05-24-184058-300x161.png\" alt=\"\" width=\"511\" height=\"274\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184128\/Screenshot-2022-05-24-184058-300x161.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184128\/Screenshot-2022-05-24-184058-768x411.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184128\/Screenshot-2022-05-24-184058-624x334.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184128\/Screenshot-2022-05-24-184058.png 878w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/p>\n<p>It is generally more useful to return the <em>position<\/em> of the maximum or minimum value rather than the value itself, especially when there is associated data like names and so on stored in <strong>parallel arrays<\/strong> or <strong>arrays of records<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-288\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184533\/Screenshot-2022-05-24-184521-300x195.png\" alt=\"\" width=\"518\" height=\"337\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184533\/Screenshot-2022-05-24-184521-300x195.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184533\/Screenshot-2022-05-24-184521-768x498.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184533\/Screenshot-2022-05-24-184521-624x405.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184533\/Screenshot-2022-05-24-184521.png 882w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><\/p>\n<p><strong style=\"color: red\">Example in Python Finding Maximum<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-274\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180147\/Screenshot-2022-05-24-180010-300x127.png\" alt=\"\" width=\"718\" height=\"304\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180147\/Screenshot-2022-05-24-180010-300x127.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180147\/Screenshot-2022-05-24-180010-1024x435.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180147\/Screenshot-2022-05-24-180010-768x326.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180147\/Screenshot-2022-05-24-180010-624x265.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180147\/Screenshot-2022-05-24-180010.png 1050w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-275\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180201\/Screenshot-2022-05-24-180125-300x151.png\" alt=\"\" width=\"910\" height=\"458\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180201\/Screenshot-2022-05-24-180125-300x151.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180201\/Screenshot-2022-05-24-180125-1024x515.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180201\/Screenshot-2022-05-24-180125-768x386.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180201\/Screenshot-2022-05-24-180125-624x314.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24180201\/Screenshot-2022-05-24-180125.png 1042w\" sizes=\"auto, (max-width: 910px) 100vw, 910px\" \/><\/p>\n<p><strong style=\"color: red\">Example in Pseudocode &#8211; Finding Minimum<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-289\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184556\/Screenshot-2022-05-24-184416-300x161.png\" alt=\"\" width=\"553\" height=\"297\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184556\/Screenshot-2022-05-24-184416-300x161.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184556\/Screenshot-2022-05-24-184416-768x412.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184556\/Screenshot-2022-05-24-184416-624x335.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184556\/Screenshot-2022-05-24-184416.png 868w\" sizes=\"auto, (max-width: 553px) 100vw, 553px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-290\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184619\/Screenshot-2022-05-24-184521-1-300x195.png\" alt=\"\" width=\"551\" height=\"358\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184619\/Screenshot-2022-05-24-184521-1-300x195.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184619\/Screenshot-2022-05-24-184521-1-768x498.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184619\/Screenshot-2022-05-24-184521-1-624x405.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184619\/Screenshot-2022-05-24-184521-1.png 882w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\" \/><\/p>\n<p><strong style=\"color: red\">Example in Python- Finding Minimum<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-291\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184803\/Screenshot-2022-05-24-184749-300x124.png\" alt=\"\" width=\"936\" height=\"387\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184803\/Screenshot-2022-05-24-184749-300x124.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184803\/Screenshot-2022-05-24-184749-1024x423.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184803\/Screenshot-2022-05-24-184749-768x317.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184803\/Screenshot-2022-05-24-184749-624x258.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184803\/Screenshot-2022-05-24-184749.png 1045w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-292\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184814\/Screenshot-2022-05-24-184714-300x143.png\" alt=\"\" width=\"942\" height=\"449\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184814\/Screenshot-2022-05-24-184714-300x143.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184814\/Screenshot-2022-05-24-184714-1024x488.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184814\/Screenshot-2022-05-24-184714-768x366.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184814\/Screenshot-2022-05-24-184714-624x297.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/24184814\/Screenshot-2022-05-24-184714.png 1041w\" sizes=\"auto, (max-width: 942px) 100vw, 942px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Because of the regularity with which these processes occur in different problems, they are known as standard algorithms.\u00a0 Each of the following 5 algorithms covered on the next few pages would typically be implemented as a function or procedure. Input Validation (Nat 5 algorithm) Input validation is used to ensure that the user enters only [&hellip;]<\/p>\n","protected":false},"author":79984,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-265","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages\/265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/users\/79984"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/comments?post=265"}],"version-history":[{"count":10,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages\/265\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages\/265\/revisions\/293"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/media?parent=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}