While not every elevator system has a unified algorithm, a popular system is the Nearest Elevator or Nearest Car (NC) algorithm.
When a call button is pressed, each elevator (if more than one), or one elevator (calculated if more than one call is present) calculates the FS (figure of suitability) score.
If the elevator is moving toward the call and the requested direction is in the same direction that the elevator is moving, the FS score is (N+2)-d, with N = total number of floors -1, and d = distance (in # of floors) from elevator.
If the elevator is moving toward the call, but the requested direction is in the opposite direction of that which the elevator is moving, the FS score is (F+1)-d, with the same variables as the previous equation.
Finally, if the elevator is moving away from the call, FS = 1.
The elevator (in the case of more than one elevator in motion) or call (in the case of one elevator with multiple calls) is summoned for the call.
The elevator then moves in the direction of the next call or waits at the last floor it was called to until the next call.
Each element: the human caller, the call button which signals the location and direction of the call, the elevator and its motion, and the buttons inside to indicate future direction/location interconnect using the algorithm and mechanisms to create a (sometimes) efficient mode of vertical travel.