The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD2017 - Answer the requirement: Take it to the maximum

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)

Array Max Min 1.png

 

b)

Array Max Min 2.png

 

c)

Array Max Min 3.png

 

d)

Array Max Min 4.png

 

 

Combined.png

Comments
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.

Combined.png

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

 

takeittothemaximum.png

 

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

Answer: B.  Nice one all. 

Combined.png

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.