Here no matter the size of the input, the display_first_cube
has to allocate memory only once for the result
variable. Hence the Big(O)
notation for the space complexity of the “display_first_cube” will be O(1)
which is basically O(c)
i.e. constant.
Similarly, the space complexity of the display_all_cubes
function will be O(n)
since for each item in the input, space has to be allocated in memory.