The Daily CLAD

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

Re: CLAD2017 - Answer the requirement: Take it to the maximum

SercoSteveB
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

 

 

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

crossrulz
Knight of NI

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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
GladysToMeetYou
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?

SercoSteveB
Active Participant

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

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

crossrulz
Knight of NI

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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Ellie90
Member

B

CataM
NI Employee (retired)

b)

nik35324
Member

B

qubirt
Member

B

Gregory
Trusted Enthusiast

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

alexderjuengere
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

 

SercoSteveB
Active Participant

Answer: B.  Nice one all. 

MAX_2019
Member

B

Mouhtedi
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 

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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Oleksiy7979
Member

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

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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Oleksiy7979
Member

Thanks. I get it now.

istan0227
Member

B