The Daily CLAD

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

Re: Array Searching #2

SercoSteveB
Active Participant

What are the contents of 'Search Position Out' following execution of the VI?

Search 2D Array 2.png

The other case for the case structure used in the question is shown below:

case strucutre.JPG

a) A 1D Array containing {-1,-1}
b) A 1D Array containing {0,0}
c) A 1D Array containing {0,2}
d) A 1D Array containing {2,0}

Comments
ambaum01
Member

c

Aaron M. Baumer
crossrulz
Knight of NI

A

Only the last iteration matters.  Therefore only the second row matters.  Is there a 3 in the second row?  Nope, so the Search 1D Array will return a -1.  So the contents of the -1 case will be the output.


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
mini09
Active Participant

A is the answer but expect an brief explanation for the flow of program.

crossrulz
Knight of NI

Look at my comment above.  If you are still lost, tell us where you are stuck.


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
Asha_Nagaraj
Member

Ans:- A

Neelamma
Member

Asha i agree with u

according to me ANS :- A       

SercoSteveB
Active Participant

Answer: A.  Nice one crossrulz, gnshmrthy, Asha_Nagaraj & Neelamma

Same as yesterday; For loops auto-index rows and Search 1D Array returns -1 for 'not found', with the addition of a little reminder to never forget the dataflow paradigm.

Musale
Member

can anyone explain me why Search 1D array giving output -1. there is 3 already in the array constant.??

SercoSteveB
Active Participant

Hi Musale and welcome to The Daily CLAD.

There is a dataflow part to this question as well as the Search 1D Array. 

On the first iteration of the loop the Search 1D Array returns 2 as it finds the '3' (at index 2) within the first (auto-indexed) row of the 2D array.  The VI does not complete and goes on to perform a second iteration.  On the second iteration, on row 2 of the 2D array, the Search Array fails to find a match and returns -1.  The -1 case of the Case Structure passes the {-1,-1} array to the output tunnel of the For Loop.

Hope this helps

Steve

skian
Member

A