Site icon TestingDocs.com

How to find the minimum value in an array flowchart

Overview

In this post, we will create a flowchart to find the minimum value in an array. We will use the RAPTOR flowchart. We will keep track of the lowest value in an array using a tracking variable LowestValue. We will assign the first value of the array to this variable.

The first value in the array is :

array_variable[1]

For example marks[1]

To read values into an array, follow the link:

https://www.testingdocs.com/questions/how-to-read-values-into-an-array-using-raptor-flowchart/

 

 

 

 

After the loop iteration, we will have the minimum array element in the tracking variable. We can use the output symbol to print the lowest element.

Flowchart

Let’s create the flowchart to find the lowest element in the array: marks

FindMin is the RAPTOR procedure that takes the marks array as an input parameter. We can call this procedure using the Call symbol.

 

 

In a loop, we will check every element in the array if the element is lesser than this variable. If the array element is lesser than we store this array element in the tracking variable.

LowestValue <- marks[index]

If the array element is greater than the tracking variable then we already have the minimum value so far in the tracking variable.

Pseudocode

   FUNCTION FindMin(marks)

      DECLARE index
      DECLARE LowestValue
 
      LowestValue = marks(1)
      index = 1
      DO UNTIL index > 5
         IF marks(index) < LowestValue THEN
            LowestValue = marks(index)
         ELSE
         END IF
         index = index + 1
      LOOP
      OUTPUT "The lowest value in the array=" + LowestValue
   
    END FUNCTION

 

Common mistakes:

In the RAPTOR flowchart, the array index starts with 1 and not with zero. We can’t use marks[0] to denote the first element, unlike in other programming languages like C, Java etc.

can't use 0 as an array index

We know that Alice has 5 subjects. So the index starts with 1 and ends with 5. We can’t access the array with a higher number as the index. index of the array should be within the interval 1 and length_of(marks)

 

Raptor Tutorials on this website can be found at:

https://www.testingdocs.com/raptor-a-flowchart-tool/

RAPTOR official website: https://raptor.martincarlisle.com/

 

Exit mobile version