Convert BFS code for a graph into a DFS code
问题 I'm sorry if this question sounds ambiguous but I was asked this in an interview. Write a program for BFS in a graph/tree. I wrote the popular code using a queue. Now he asked me to convert it to a DFS code by modifying just one line of the BFS code I had just written. The only answer I could think of was to use a stack for DFS. Then I implemented the stack using 2 queues. So in the end my answer was: use 1 queue for BFS. for DFS use 2 queues instead. He did not give me any feedback . Wasn't