Explain how a breadth-first traversal of a graph works.
What will be an ideal response?
A breadth-first traversal of a graph uses a queue as a supporting data structure. It begins enqueuing the
starting vertex and marking it as visited. After that, it iterates a loop until the queue is empty. At each iteration, it dequeues the
first element in the queue, enqueues all of its unvisited neighboring vertices, and then marks them all as visited. At the end of
this process, all of the vertices will have been visited (assuming the graph is connected).
You might also like to view...
Suppose you have the following struct definition and typedef statements in your program:
What will be an ideal response? ``` struct N { double d; N *next; }; typedef N* node_ptr; node_ptr p1; Now suppose further that p1 points to a node of type N in a linked list. Write code that makes p1 point to the next node on the linked list. ```
To pause for a designated number of milliseconds and resume execution, a thread should call method __________ of class ____________.
Fill in the blank(s) with the appropriate word(s).