While loops are often used to process elements in an array. Search shall be aborted either when a given condition is fullfilled or when all array elements have been processed. For this reason one has - outside the while loop - to get the array size, decrement by 1 and - inside the loop - compare this number with the actual iteration terminal. This must be combined with the result of the above mentioned processing in order to determine if the loop must reiterate or stop. if instead a 'last element' terminal in the loop was provided, the explicite calculations aouside of the loop could be avoided and with it the real estate this takes.
BTW, 'last element' should keep true whenever it became true in a loops execution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.