{"id":5854,"date":"2017-01-03T09:15:36","date_gmt":"2017-01-03T09:15:36","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=5854"},"modified":"2025-02-27T17:55:16","modified_gmt":"2025-02-27T17:55:16","slug":"how-to-find-the-largest-value-in-an-array-flowchart","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-find-the-largest-value-in-an-array-flowchart\/","title":{"rendered":"How to find the largest value in an array Flowchart"},"content":{"rendered":"<h2>How to find the largest value in an Array Flowchart<\/h2>\n<p>In this post, we will create a flowchart to find the largest value in an array. We will use the RAPTOR flowchart. We will keep track of the largest value in an array using a tracking variable <strong>LargestValue<\/strong>. We will assign the first value of the array to this variable.<\/p>\n<p>The first value in the array is :<\/p>\n<p>array_variable[1]<\/p>\n<p>For example: marks[1]<\/p>\n<p>To read values into an array, follow the link:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.testingdocs.com\/questions\/how-to-read-values-into-an-array-using-raptor-flowchart\/\">https:\/\/www.testingdocs.com\/questions\/how-to-read-values-into-an-array-using-raptor-flowchart\/<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5867\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/array-values-in-RAPTOR-flowchart.png\" alt=\"array values in RAPTOR flowchart\" width=\"1304\" height=\"833\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/array-values-in-RAPTOR-flowchart.png 1304w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/array-values-in-RAPTOR-flowchart-300x192.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/array-values-in-RAPTOR-flowchart-1024x654.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/array-values-in-RAPTOR-flowchart-768x491.png 768w\" sizes=\"auto, (max-width: 1304px) 100vw, 1304px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>After the loop iteration, we will have the maximum array element in the tracking variable. We can use the output symbol to print the maximum element.<\/p>\n<h2>Flowchart<\/h2>\n<p>Let&#8217;s create the flowchart to find the maximum element in the array: marks<\/p>\n<p>FindMax is the RAPTOR procedure that takes the marks array as an input parameter. We can call this procedure using the Call symbol.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5863\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/largest-value-in-an-array-flowchart.png\" alt=\"In this post, we will create a flowchart to find the largest value in an array. We will use the RAPTOR flowchart. We will keep track the largest value in an array using a tracking variable\" width=\"1712\" height=\"1012\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/largest-value-in-an-array-flowchart.png 1712w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/largest-value-in-an-array-flowchart-300x177.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/largest-value-in-an-array-flowchart-1024x605.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/largest-value-in-an-array-flowchart-768x454.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/largest-value-in-an-array-flowchart-1536x908.png 1536w\" sizes=\"auto, (max-width: 1712px) 100vw, 1712px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>marks[index] &gt; LargestValue<\/p>\n<p>In a loop, we will check every element in the array if the element is greater than this variable. If the array element is greater than, we store this array element in the tracking variable.<\/p>\n<p>LargestValue &lt;- marks[index]<\/p>\n<p>If the array element is less than the tracking variable, then we already have the maximum value so far in the tracking variable.<\/p>\n<h2>Pseudocode<\/h2>\n<pre>   FUNCTION FindMax(marks)\r\n\r\n      DECLARE index\r\n      DECLARE LargestValue\r\n \r\n      LargestValue = marks(1)\r\n      index = 1\r\n      DO UNTIL index &gt; 5\r\n         IF marks(index) &gt; LargestValue THEN\r\n            LargestValue = marks(index)\r\n         ELSE\r\n         END IF\r\n         index = index + 1\r\n      LOOP\r\n      OUTPUT \"The largest value in the array=\" + LargestValue\r\n   \r\n    END FUNCTION\r\n<\/pre>\n<h2>Common mistakes:<\/h2>\n<p>In RAPTOR flowchart, array index starts with 1 and not with zero. We can&#8217;t use marks[0] to denote the first element, unlike in other programming languages like C, Java, etc.<\/p>\n<p>You will get the following error:<\/p>\n<pre>can't use 0 as an array index<\/pre>\n<p>We know that Alice has 5 subjects. So the index starts with 1 and ends with 5. We can&#8217;t access the array with a higher number than the index. For example, we can&#8217;t access marks[6]. This will return an error because the array doesn&#8217;t have 6 elements.<\/p>\n<pre>marks doesn't have 6 elements.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to find the largest value in an Array Flowchart In this post, we will create a flowchart to find the largest value in an array. We will use the RAPTOR flowchart. We will keep track of the largest value in an array using a tracking variable LargestValue. We will assign the first value of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[187],"tags":[208],"class_list":["post-5854","post","type-post","status-publish","format-standard","hentry","category-flowchart","tag-mathematics","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/5854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=5854"}],"version-history":[{"count":37,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/5854\/revisions"}],"predecessor-version":[{"id":26973,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/5854\/revisions\/26973"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=5854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=5854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=5854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}