LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD prep example question help please

Solved!
Go to solution

I thought that the SRs would ONLY be re-initialized when the VI was stopped and then re-started, not when the LOOP goes through the iterations. The values I saw in between the outer loop & inner loop SRs were: 0,1,2; 2,0,1;& 1,2,0. What I saw feeding the top of the outer SR (or the indicator) was 2, then 1, then 3 the final answer.......

 

I think I am more confused now than ever! 🙂

 

VI attached!

 

G

0 Kudos
Message 11 of 19
(2,005 Views)

The inner loop is indeed stopped (after it runs 2 times) and re-started (the next iteration of the outer loop).

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 12 of 19
(1,990 Views)
Solution
Accepted by topic author LvTech

@LvTech wrote:

Hi,

 

I am taking multiple practice tests in preparation for the CLAD. My weak spot seems to be questions where you need to say what the output of a loop within a loop will be. For the below example, is there a way to approach this problem without going through each iteration in my head & trying to keep track of the values that will be in each of these stacked shift registers after every iteration? Gets very confusing because not allowed to have paper and pencil to note things during the exam. I am creating these examples in LabVIEW and stepping through hem to follow the data flow, but wondering if there is a "faster" way to get to the solution. The choices given as possible answers in this example are: 0, 1, 2, or 3. 

 

Thanks for the help!

 

George

 

 

What is the value in Numeric Value Out after the following has executed?

 

LvTech_0-1648047969674.png

 

 


OK let's go through quick.  The SR elements are N-0, N-1 and N-2 initialized to 0,1,2 on i 0,i 0

 

The inner loop runs once  incrementing N -2  and placing the result in the SR for a 3,0,1 and again 1+1 = 2,3,0. The 2 is stuck back to the OUTER SR so iteration 2 starts with 2,1,0 and the inner loop SR is reinitialized to that.  Running the inner loop leaves 1,2,2 and the 1 is place back for i3 of 1,2,1. And we reinit the inner loop again 

 

So two iterations later the SR 0th element will be (drum roll) N-1 incremented of course or 3

 

And yes, it's probably the strangest way to increment element n-1 ever.


"Should be" isn't "Is" -Jay
Message 13 of 19
(1,984 Views)

I think the answer to things like these is like you'd do with an algebra equation:  Simplify until it looks like something you can handle.

 

Start by looking at the middle loop.  Since it iterates a fixed amount of times, the output can be replaced by a fixed set of math done on its input.  In this case, it always just outputs the middle value of its 3 inputs with a +1 to its value.  So you simplify that down to do just that:

Kyle97330_0-1648080763504.png

After that, it's pretty easy to see that a lot of wires and nodes can be removed as they contribute nothing.  The bottom shift register on the left and everything connected to it, plus the wire on the top shift register on the left, and the structure are all no-ops.  Remove them and it looks like this:

Kyle97330_2-1648080907253.png

From here it's not too hard to work out the values in your head since there's now far fewer to keep track of, and hopefully you can figure out what's happening.  It basically simplifies to this:

 

Kyle97330_3-1648081369036.png

But since the effort to simplify that is probably equal to the effort to just mentally iterate the 3 loops, there's not a huge need to bother and stopping at the step before and just answering is probably best.

 

Message 14 of 19
(1,971 Views)

Announcing a Kudos bounty for finding the moot error in my solution. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 15 of 19
(1,859 Views)

Ok, I'll play along.  When I read your msg before, a couple details didn't match my notes, but they were things that didn't propagate forward to affect the final answer.  I figured it was just a typo-level mistake, ignored it, and kudo'ed the answer anyway.  I just went back through it again to check, here's what I had different:

 

The inner loop runs once  incrementing N -2  and placing the result in the SR for a 3,0,1 and again 1+1 = 2,3,0. The 2 is stuck back to the OUTER SR so iteration 2 starts with 2,1,0 and the inner loop SR is reinitialized to that. 

 

I have iteration 2 of the outer loop starting 2,0,1.  This naturally leads to the other diff...

 

Running the inner loop leaves 1,2,2 and the 1 is place back for i3 of 1,2,1

 

I have i3 of the outer loop starting at 1,2,0.

 

But the element in dispute has no influence on the final answer of 3 anyway.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 16 of 19
(1,845 Views)

Thanks Kevin

It was a typo and moot but after the solution got marked I wanted to have it addressed.


"Should be" isn't "Is" -Jay
0 Kudos
Message 17 of 19
(1,840 Views)

I must say, I especially liked the way Kyle97330 broke it down in msg #14.  A really nice bit of analytic thinking -- I consider him the real winner of this thread!

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 18 of 19
(1,827 Views)

@Kevin_Price wrote:

I must say, I especially liked the way Kyle97330 broke it down in msg #14.  A really nice bit of analytic thinking -- I consider him the real winner of this thread!

 

 

-Kevin P


Regardless of how silly the puzzle is or how it is solved the examinees must know two things

  • How many iterations of delay each SR element represents 
  • When each element is initialized or reinitialized. 

So it's a fair puzzle since, with the values shown, either or both mistakes yield the other 3 distractors.  It does the job of testing the knowledge.   It should trigger a whole lot of derogatory laughter in a code review. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 19 of 19
(1,812 Views)