hi all,
QUESTION 1
I had a doubt regarding the space complexity during inorder traversal.
To print the inorder traversal, I am using an array called "elements" to store the result of the traversal. will this array be counted towards the space complexity and because of this my resultant space complexity will become O(n) with n being the number of nodes in the tree?
QUESTION 2:
If I dont use a separate array to store values after sorting instead I directly write
if array == sorted(array):
return True
Even though I am not explicitly using a variable to store the sorted array, will sorted(array) take some space and wll it contribute towards space complexity?
I feel it will but still wanted to clarify
Thanks!