Tag - explain the space and time complexity of the algorithm with an example