In a digital document archiving facility, a robotic arm is used to manage vertical stacks of historical document folders.
There are three archiving trays: Tray X, Tray Y, and Tray Z.
Develop an algorithm, using either pseudo-code or a flowchart, that will transfer all document folders from Tray X to Tray Z.
Your algorithm must work regardless of how many folders are initially stacked in Tray X. You can assume there is always at least one folder in Tray X at the start, and that Tray Y and Tray Z are completely empty.
The vertical order of the folders must be preserved in the final stack on Tray Z (i.e. the folder that starts at the top of the stack in Tray X must end up at the top of the stack in Tray Z).
You must use only the following subroutines in your solution:
TRANSFER_FOLDER(source, destination): Moves the top folder from the source tray and places it on top of the stack in the destination tray.COUNT_FOLDERS(tray): Returns the number of folders currently stacked in the specified tray.For example, if the starting arrangement is:
Then the final arrangement must have Folder [2] stacked on top of Folder [1] in Tray Z, with Tray X and Tray Y being empty.