Using local variable is not a crime.
Nothing to do with local variables.
It is almost a crime to give a new student horribly complicated advice if, as in this case, much better, simpler and cleaner solutions exist. Soon the students thinks that LabVIEW is way too hard and give up.
Show them a concise, efficient and easy to understand solution and they will appreciate the beauty and simplicty of LabVIEW and will be happy to learn more. LabVIEW is fun!
You don't teach a little kid how to walk by leading it into a swamp. Too many alligators! 😄
In this case indexing the output using the conditional mode (LV2012 and later) can be very useful...
Sometimes it is OK to show a more complicated alternative solution to teach some useful techniques. Here is one such solution. 😄
Try to understand the exact reason for each of the operations shown (maybe the discussion in this idea can give you some clues because with the idea implemented, we could do a completely loop-free solution :D). Also try to figure out why we need the case structure (and if you cannot load the snippet, what is contained in the other case ;)).
Yes, the obvious solution, except that a case structure would cut the number of array operations in half.
However these corcion dots on the bitwise operation make me cringe. Do you know why they are there? 😄
Probably the most efficient way would be to operate on the original array in place in a shift register and going through it from both ends at once similar to the "quickselect" algorithm. Instead of using a pivot value we select between even and odd and swap misplaced elements pairwise until the indices meet, followed by an array split as shown in my earlier code.
Would be an interesting exercise. 😄 I remember writing an efficient implementation in the old median challenge that could be re-used with minor changes. (Cannot find the link. Were are these discussions???)
does it have something to do with memory use for efficiency in that 'in place' was developed?
sorry for the hijack...