mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Update graph bfs challenge
Add more detail to algorithm space complexity.
This commit is contained in:
parent
2d98b8a496
commit
9a321b9f15
|
@ -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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user