mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
Update graph bfs challenge (#118)
Add more detail to algorithm space complexity.
This commit is contained in:
@@ -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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user