Challenge Summary
The challenge asks to implement breadth first function that takes a vertex in a graph and returns list of vertices in breadth first order.
Whiteboard Process
Approach & Efficiency
Time complexity for breath first function is O(v) since v is number of vertices on that island. Space complexity is O(v) since we are declaring a new list of length v which is number of vertices on that island and creating them visited set of size v as well.
Solution
you can use this function by declaring a graph and adding vertices and edges to it then call graphName.breadthFirst(vertex)
.