{"id":1146,"date":"2016-04-07T21:24:21","date_gmt":"2016-04-07T21:24:21","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/?p=1146"},"modified":"2016-04-07T09:33:47","modified_gmt":"2016-04-07T09:33:47","slug":"higher-algorithm-specification","status":"publish","type":"post","link":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/2016\/04\/07\/higher-algorithm-specification\/","title":{"rendered":"Higher &#8211; Algorithm Specification (Revision)"},"content":{"rendered":"<p><strong>Input Validation<\/strong>: making sure that the data input by the user is acceptable e.g. in a suitable format and within the upper and lower limits of the data required by the software<\/p>\n<pre>RECEIVE userInput FROM (INTEGER) KEYBOARD\r\nWHILE userInput &lt; lowerLimit OR userInput &gt; uperLimit DO\r\n    SEND \u201cInput must be between\u201d &amp; lowerLimit &amp; \u201cand\u201d &amp; upperLimit TO DISPLAY\r\n    RECEIVE userInput FROM (INTEGER) KEYBOARD\r\nEND WHILE\r\n<\/pre>\n<p><strong>Linear Search (efficient)<\/strong>: sets a Boolean variable to false initially and uses an unconditional loop to set it to true when the item is found; the loop terminates when the item is found or the end of the array is reached<\/p>\n<pre>RECEIVE itemToFind FROM (INTEGER) KEYBOARD\r\nSET found to false\r\nSET arraySize to higestIndex\r\nSET counter TO 0\r\n\r\nWHILE counter &lt;= arraySize AND found = false\r\n    SET counter to counter + 1\r\n    IF array[counter] = itemToFind THEN\r\n        found=true\r\n    END IF\r\nEND WHILE\r\n\r\nIF found = true THEN\r\n    SEND itemToFind &amp; \u201cfound at position\u201d &amp; counter TO DISPLAY\r\nELSE\r\n    SEND \u201cItem not found\u201d TO DISPLAY\r\nEND IF\r\n<\/pre>\n<p><strong>Finding Minimum<\/strong>: sets an initial value to the first item in the array then compares it to the remaining items<\/p>\n<pre>SET maxiumValue to numbers[0]\r\n\r\nFOR counter FROM 1 TO 9 DO\r\n    IF maximumValue &lt; numbers[counter] THEN\r\n        SET maximumValue to numbers[counter]\r\n    END IF\r\nEND FOR\r\n\r\nSEND \u201cThe largest value was\u201d &amp; maximumValue to DISPLAY\r\n<\/pre>\n<p><strong>Finding Maximum<\/strong>: sets an initial value to the first item in the array then compares it to the remaining items<\/p>\n<pre>SET miniumValue to numbers[0]\r\n\r\nFOR counter FROM 1 TO 9 DO\r\n    IF minimumValue &gt; numbers[counter] THEN\r\n        SET minimumValue to numbers[counter]\r\n    END IF\r\nEND FOR\r\n\r\nSEND \u201cThe smallest value was\u201d &amp; minimumValue to DISPLAY\r\n<\/pre>\n<p><strong>Count Occurrences<\/strong>: sets a total to zero at the beginning and increments it as items are found to match the search item<\/p>\n<pre>RECEIVE itemToFind FROM (INTEGER) KEYBOARD\r\nSET numberFound to 0\r\n\r\nFOR EACH number FROM numbers DO\r\n    IF number=itemToFind THEN\r\n        SET numberFound to numberFound+1\r\n    END IF\r\nEND FOR EACH\r\n\r\nSEND \u201cThere were\u201d &amp; numberFound &amp; \u201coccurreneces of\u201d &amp; itemToFind &amp; \u201cin the list\u201d TO DISPLAY\r\n<\/pre>\n<p>Thank you to C O\u2019Toole &amp; A Madill from Braidhurst High School for allowing me to edit and publish this here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Input Validation: making sure that the data input by the user is acceptable e.g. in a suitable format and within the upper and lower limits of the data required by the software RECEIVE userInput FROM (INTEGER) KEYBOARD WHILE userInput &lt; lowerLimit OR userInput &gt; uperLimit DO SEND \u201cInput must be between\u201d &amp; lowerLimit &amp; \u201cand\u201d &hellip;<\/p>\n","protected":false},"author":32,"featured_media":1078,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17935,319,475],"tags":[],"class_list":["post-1146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithm-specification","category-oldhigher","category-revision"],"jetpack_featured_media_url":"https:\/\/blogs.glowscotland.org.uk\/nl\/public\/ColtnessHS-ComputingScience\/uploads\/sites\/12638\/2016\/03\/higher.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/1146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/comments?post=1146"}],"version-history":[{"count":3,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/1146\/revisions"}],"predecessor-version":[{"id":1151,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/posts\/1146\/revisions\/1151"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/media\/1078"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/media?parent=1146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/categories?post=1146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/nl\/ColtnessHS-ComputingScience\/wp-json\/wp\/v2\/tags?post=1146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}