Computer Science, asked by devendra123world, 6 months ago

Write a program to traverse graph data structure using queue and stack data structure i.e. BFS and DFS.​

Answers

Answered by Harshikesh16726
2

C

n−1

=(−1)

n

(1−n)Given that,

Volume of two sphere are in ratio=64:27

We know that ,

Volume of sphere=

3

4

πr

Answered by vishakasaxenasl
0

Answer:

Following are the BFS and DFS algorithms for traversing graph data structure:

BFS Algorithm

BFS stands Breadth-First Search. BFS algorithm uses the queue data structure for traversing the graph.

Following are the steps on BFS:

  • Start with any node of the graph and insert it into the queue.
  • Now insert its neighboring nodes in the queue one by one.
  • When a neighbor node is inserted, the previous node is deleted from the queue and traversed.
  • These two steps are repeated until on the nodes are visited and the queue becomes empty.

DFS Algorithm

DFS stands Depth-First Search. DFS uses the stack data structure for traversing the graph.

Following are the steps of DFS:

  • Start with any node of the graph and insert it into the stack.
  • Now insert its neighboring nodes in the stack one by one.
  • When all the nodes are inserted in the stack, pop the nodes one by one from the top of the stack.
  • Repeat this step until the stack becomes empty.

#SPJ3

Similar questions