Which data structures are used for BFS and DFS?

Hello Everyone, I am new here and I want to know which data structures are used for BFS and DFS? In my last interview, I have faced this question but I didn’t know those answers. Can anyone knows and help me out or suggest some data structure based interview questions as a beginner point.

1 Like

Hey @ankitdixit! Welcome to the community!
This forum is dedicated to blockchain topics. You’d be better of looking at websites like stackoverflow for general CS help.
Going back to your question BFS uses Queue there DFS uses Stack. Hope it helps!

1 Like

Hi @ankitdixit,

Welcome to the community :wave:

Was this for a blockchain developer role?

I didn’t know what the terms were: Breadth first search (BFS) and depth first search (DFS)
https://www.ics.uci.edu/~eppstein/161/960215.html

Were you looking for data structures in Solidity?

I Totally, Agree with your points, Yes this question is valid for those data science forums where you can get the perfect answers, I am a developer as well, but as you asked, So here sharing with your answer of the difference between BFS and DFS.


For Data Science Interview Questions, I am going to list out questions which are asked in the interviews:

  • 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?
  • Question: What is the difference between NULL and VOID?
  • Question: How does a POP operation differ from a PUSH operation?
  • Question: Could you explain how does variable declaration affect memory allocation?
  • Question: Please explain the concept of data abstraction.
  • Question: How will you insert a new item in a binary search tree?
  • Question: Could you explain how does the selection sort work on an array?
  • Question: Do you know how the memory is affected by signed and unsigned numbers?
  • Question: Does all declaration statements result in a fixed memory reservation?
  • Question: How does an array differ from a stack?
  • Question: What do you understand by an AVL tree?
  • Question: Please explain how does an Array differ from a Linked List?
  • Question: What do you understand by Infix, Prefix, and Postfix notations?
  • Question: Please explain the Linked List and its various types.
  • Question: How will you implement a stack using queue and vice-versa?
  • Question: Which data structures are used for implementing LRU cache?
  • Question: Could you give a brief explanation of the various approaches for developing algorithms?
  • Question: Please enumerate some examples of greedy and divide and conquer algorithms.
  • Question: How does insertion sort differ from selection sort?
  • Question: What do you understand by shell sort?
  • Question: Can you explain tree traversal?
  • Question: Please explain a spanning tree. What is the maximum number of spanning trees a graph can have?
  • Question: How does the Kruskal’s Algorithm work?
  • Question: What do you understand by Heap in data structure?
  • Question: Please explain recursion.
  • Question: Can you explain the Tower of Hanoi problem?
  • Question: How do the BFS (Breadth-First Search) and DFS (Depth First Search) algorithms work?
  • Question: What do you understand by hashing?
  • Question: Please explain an MST (Minimum Spanning Tree). Also, explain how does Prim’s algorithm find a minimum spanning tree.
  • Question: Can you explain the interpolation search technique?
  • Question: How will you check whether the given Binary Tree is BST or not?

Getting answer of these questions read our blog.

2 Likes

Hi @Rohan_Joshi,

Welcome to the community :wave:
Thanks for providing an answer on BFS and DFS. Also nice plug for your blog :+1:

1 Like

Thanks @Rohan_Joshi to provide great information.

1 Like