cancel
Showing results for
Did you mean:

Active Participant

You are asked to write a VI that will take in a 1D Array of numeric values and output the maximum value found within the array (Maximum Value Out) and the array index of the maximum value (Maximum Value Index Out).  If two or more elements within the array contain the maximum value the VI should output the lowest array index found containing that value.  NOTE:  All elements in the array have a value of greater than or equal to zero.

Which of the following VIs does NOT satisfy the requirements?

Have a go at coding a VI yourself or expand the Spoiler tag to see the answer options.

Spoiler

a)

b)

c)

d)

Member

Assuming a 1D Array as the input, B would be the choice that doesn't meet the requirements.

However, you mention using a 2D Array in the description and choice 'A' would not Run as written since you'd be trying to wire in a 2D Array into functions that require a 1D Array.

Knight of NI

All of them fail to meet the requirement of having a 2D array for the input.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

Correct me if I’m wrong, but wouldn’t C work, assuming you created a new indicator for the max value index to accommodate the output being a 1D array and not a scalar value?

Active Participant

Good point well made, I am not sure where 2D array came from.  Question modified to 1D array.

Member

B is the VI that doesn't meet the requirements.

By the way, the other three VIs would produce different outputs if they receive an empty array input.

Knight of NI

B because of the Greater Or Equal.  My initial thought for how to do the code was C.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

B

NI Employee

b)

Member

B

Member

B

Trusted Enthusiast

B and D do not satisfy the requirements if there are only negative values in the array.

CLA // LabVIEW 2016 // BALUG // Unofficial Forum Rules and Guidelines
Active Participant

almost missed this requirement

" If two or more elements within the array contain the maximum value the VI should output the lowest array index found containing that value"

so, as crossrulz already pointed out, it's B

People don’t do what you expect, but what you inspect.
- Louis V. Gerstner, IBM
Active Participant

Member

B

Member

HI,
the correct answer a) and C)
because
1-the question is "Which of the following VIs does NOT satisfy the requirements?"
2-" If two or more elements within the array contain the maximum value the VI should output the lowest array index found containing that value"

3-All elements in the array have a value of greater than or equal to zero in response a) and c) if All elements in the array have a value of less than or equal to zero allows to resize the "max value out " and "the max index value out" to zero

Knight of NI

Mouhtedi,

I am not sure what you are trying to state with 3.  But A and C clearly meet the requirements in that they return the lowest index maximum.  Besides, Steve has already told us the answer was indeed B.  The reason being that B will give the LAST index maximum.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

"Lowest array index" mean a smaller index number or a larger index number? I assume that smaller, then a) meets the requirement.

Knight of NI

Oleksiy,

Read the question again.  It is asking which one does NOT meet the requirement.  A, C, and D all meet the requirement.  B does not.  So the answer is B.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

Thanks. I get it now.