Update graph bfs challenge

Add more detail to algorithm space complexity.
This commit is contained in:
Donne Martin 2016-11-14 06:39:16 -05:00
parent 2d98b8a496
commit 9a321b9f15

View File

@ -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)"
]
},
{