The answer for all three situations is supposedly 3, i dont understand why that is, can someone please explain what is going on and the reasoning behind it, why is the answer 3 for all situations ?
I am new to code, a beginner and need help.
Here is the code
Z [], T = Z[1] Z.SIZE>1 T = T+Z[Z.SIZE] T
What does this process out in the following situations ?
Z[] = [1,2]
Z[] = [1,2,3]
Z[] = [3]
I dont understand the result of the array, i dont understand the logic behind it. I need a simple and easy to understand explanation of the results.
That pseudocode looks unusual: all the code is presented on the same line (bad!), no keywords like
iforwhileorfor... No clear indication what part is conditional, and what is not. This is atypical in honestly does not pass the standard of what pseudocode is supposed to look like.I will have a guess at what this code means:
...rewriting it in propper pseudocode:
This function takes the first element of
Zand the last element ofZ(ifZhas more than one element), and returns the sum of these.So then we have these expected outputs:
Z = [1,2]will result in 3Z = [1,2,3]will result in 4Z = [3]will result in 3