Hello Everyone, Can anyone tell which data structures are used for BFS and DFS of a graph? I am confused between both of them. I also want to know specific work for BFS and DFS in the graph. I am preparing some database structure interview questions for my upcoming interview. Can anyone suggest me some tips for database profile?
Here is the answer:
BFS(Breadth First Search) uses Queue data structure for finding the shortest path. DFS(Depth First Search) uses Stack data structure . 3. BFS can be used to find single source shortest path in an unweighted graph, because in BFS, we reach a vertex with minimum number of edges from a source vertex.
So the final answer is BFS is used for Graph Data base.
For more interview questions visit here:
Question: What do you understand by a data structure?
Question: How does a linear data structure differ from a non-linear data structure?
Question: Please enumerate the various operations that can be performed on a data structure.
Question: Can you tell which data structures are used for BFS and DFS of a graph?
Question: Please explain stack and also mention some of its important applications.
Question: What is a queue? How is it different from a stack?
Question: What do you understand by a binary search? What is the best scenario of using it?
Question: Could you explain how to reference all the elements in a one-dimension array?
Question: Please explain what do you understand by FIFO and LIFO?
Question: Do you know how does dynamic memory allocation help in managing data?