Big(O) Notation for Space Complexity
To find space complexity, we simply calculate the space (working storage, or memory) that the algorithm will need to allocate against the items in the inputs. Let’s again take a look at the display_first_cube
function.
xxxxxxxxxx
function displayFirstCube(items) {
const result = Math.pow(items[0], 3);
console.log(result);
}
const inputs = [2, 3, 4, 5, 6, 7];
displayFirstCube(inputs);
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment