I was doing inorder traversals when in the solution I came across the following lines:
stack.push(current);
current = current.left;
Now my question is that when I push current into the stack and make current = current.left;
then will the node that is there within the stack
also change to current.left
? In my case, the current in the stack
still points to the original current
but the current
variable does point to current.left
. Why is this?