On a website it gives you questions and answers for computer science, yet does not explain the answer. I was hoping if someone could explain the pseudo-code (answer) for me, as I do not understand it. Especially the store index part - which is basically the entire pseudo-code. Thank you. More specifically: line 4, line 8 and why found = False in line 4 means item is found but in line 11 means item not found.
The question is:
Write an algorithm expressed in pseudo-code to ask a user for a search item and carry out a linear search on data stored in an array to find that item (6 marks).
The answer is:
RECEIVE item FROM KEYBOARD SET found TO False SET index to 0 WHILE found = False AND index <= LENGTH(store) - 1 DO IF store[index] = item THEN SET 'Item found' TO DISPLAY ELSE SET index TO index + 1 END IF END WHILE IF found = False THEN SEND 'Item not found.' TO DISPLAY END IF