In S2 : Stack will be like this

visit a : neighbor = b,c

visit c : neighbor = d,b

visit d : neighbor = e,f

visit e : neighbor = b,f

visit b : all neighbors are visited. pop

visit f : since it is e's neighbor

Hence sequence : acdebf

visit a : neighbor = b,c

visit c : neighbor = d,b

visit d : neighbor = e,f

visit e : neighbor = b,f

visit b : all neighbors are visited. pop

visit f : since it is e's neighbor

Hence sequence : acdebf