use of stack in backtracking