diff --git a/graphs_trees/graph_bfs/bfs_solution.ipynb b/graphs_trees/graph_bfs/bfs_solution.ipynb index b4b098b..feed2c5 100644 --- a/graphs_trees/graph_bfs/bfs_solution.ipynb +++ b/graphs_trees/graph_bfs/bfs_solution.ipynb @@ -83,7 +83,12 @@ "\n", "Complexity:\n", "* Time: O(V + E), where V = number of vertices and E = number of edges\n", - "* Space: O(V + E)" + "* Space: O(V)\n", + "\n", + "Note on space complexity from [Wikipedia](https://en.wikipedia.org/wiki/Breadth-first_search):\n", + "* When the number of vertices in the graph is known ahead of time, and additional data structures are used to determine which vertices have already been added to the queue, the space complexity can be expressed as O(V) \n", + "* If the graph is represented by an adjacency list it occupies O(V + E) space in memory\n", + "* If the graph is represented by an adjacency matrix representation, it occupies O(V^2)" ] }, {