In this video, let's compare the pseudocode that we have over here with the backtracking blueprint
that we had previously discussed.
So notice over here we have the base condition.
And that's what we have over here.
If I is equal to length of the array which is given to us, then push that particular instance of the
current uh array into the results array and then return.
So that's our base condition, which is what we have over here.
And then notice that over here we have for choice in choices.
And we were doing this for each choice.
But over here in this pseudocode over here we don't need this for loop because there are just two choices
which is exclude and include.
Right.
So over here this part deals with exclude and this part where we push to the current array.
And then uh we call the function recursively.
And later we pop from the array.
So this part over here is the include part.
So we have dealt with this as well from the blueprint.
And then notice over here in this question including or excluding every element is valid.
So there is no need for this is valid check at this point.
So that is not there in the pseudocode over here.
And then finally we have the backtracking step over here which is reverting the choice.
And the choice was to push to the uh current array which would become a subset.
Now the backtracking or reverting the choice is popping that element which we just now included.
For example, node is over here.
Let's say at this point the current array had one as an element in it.
And then we excluded element the next element which is element seven.
And we got a subset which is just one.
And then we return.
We come back to this place and then we include the next element which is seven.
So the current array becomes one seven and later.
Notice over here another subset is one eight.
So whatever we added over here which is seven has to be popped out when we come back so that the array
becomes one.
And then this call returns.
And then we come over here and we are able to add 8 to 1 and it becomes one eight.
And finally from there we come over here and we get this.
So remember that's why because the changes are made in place.
That's why the backtracking step or in this case popping the element that was added is important.