Which of the following data structures is useful for traversing a given graph by breadth-first search?

a. Queue
b. List
c. Stack
d. Linked list


a. Queue
BFS performs level-order traversal that can be fairly done using a queue. A queue uses FIFO ordering and the nodes that we enqueue first are explored first maintaining the order of traversal.

Computer Science & Information Technology

You might also like to view...

How many and what kind of variables (primitive or object) are created in the code below?

> String fileName = FileChooser.pickAFile(); // fileName is an object variable. > Picture p1 = new Picture(fileName); // p1 is an object variable. > p1.show();

Computer Science & Information Technology

A class diagram resembles a horizontal flowchart that shows the actions and events as they occur.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Setting the list-style-type to hide causes the bullets in front of each list item to not be displayed.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The asterisk operator (*) is used in two different contexts: for declaration and for redirection.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology