X432: Graphs - Breadth First Traversal

Given is an adjacency matrix and a starting index.

Complete the breadth first traversal method. Comments noted with //_________________ are lines that must be completed.
Queue, LinkedList and ArrayList have been enabled. The Queue API can be viewed here:
https://docs.oracle.com/javase/7/docs/api/java/util/Queue.html

Examples:

breadthFirstTraversal({{0, 1, 0, 0},{0, 0, 1, 0},{0, 0, 0, 1}, {0, 1, 1, 0}},0) -> new java.util.ArrayList<Integer>(){{add(0);add(1);add(2);add(3);}}

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.