0

We know that for Breadth First Traversal we should use 'Queue'.

Example:
https://i.stack.imgur.com/aCzzc.png

For this graph, if we start from '0', the visit order will be like this : 0 1 3 8 7 2 4 5 6.
What would be the visit order if we use a priority queue?

Edit: Priority Queue will be min-heap.

Elvis23
  • 1
  • 4
  • 1
    Any own thoughts? – Ecto Jan 17 '21 at 23:56
  • What would the priority of a node be? – kaya3 Jan 18 '21 at 01:19
  • *"What would be the visit order"* : the nodes are pulled out by priority. You have to define and calculate the priority. Algorithms like A* and Dijkstra are often implemented using a priority queue. – c0der Jan 18 '21 at 05:08
  • Priority queue will be min-heap. Also i thought i can set the same weight to all vertices to use the Dijkstra algorithm. With that, I m not sure but i found "0 1 3 2 4 5 6 7 8". https://visualgo.net/en/sssp you can try Dijkstra on this website. – Elvis23 Jan 18 '21 at 08:41
  • anyone for help? – Elvis23 Jan 24 '21 at 20:25

0 Answers0