Based on this definition of algorithm from Wikipedia:
In mathematics and computer science, an algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning.
An algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state.
Is "Wait for user input" or simply read()
counted an step of algorithm?
I thought for the following reasons it may not fit in the definition:
- It seems it's not an step which can be executed as an operation is executed.
- It should wait for an external signal to get finished, it could be against of the self-contained in the definition.
- Moreover the definition talks about an initial input, so I suppose the input should be already provided.
Am I correct?
Update: If it's not an step, then how would you represent the following sequence, is it an algorithm?
- X = 5
- Y = X + 4
- if ( Y > 10) Z = Read() // get the user input
- else Z = 1
- if (Z > 2) Z = Z + X
Please note reading occurs conditionally, then we may not suppose the input should be already provided.