8000 Fixed two typos in mst_prim.md (#448) · cp-algorithms/cp-algorithms@51ea4b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 51ea4b4

Browse files
mrpandeyjakobkogler
authored andcommitted
Fixed two typos in mst_prim.md (#448)
* corrected typo in dijkstra_sparse.md * fixed two typos in mst_prim.md
1 parent b7d7460 commit 51ea4b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/graph/mst_prim.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ If we search the edge by iterating over all possible edges, then it takes $O(m)$
7272
The total complexity will be $O(n m)$.
7373
In the worst case this is $O(n^3)$, really slow.
7474

75-
This algorithm can be improves if we only look at one edge from each already selected vertex.
75+
This algorithm can be improved if we only look at one edge from each already selected vertex.
7676
For example we can sort the edges from each vertex in ascending order of their weights, and store a pointer to the first valid edge (i.e. an edge that goes to an non-selected vertex).
7777
Then after finding and selecting the minimal edge, we update the pointers.
78-
This give a complexity of $O(n^2 + m)$, and for sorting the edges an additional $O(m \log n)$, which gives the complexity $O(n^2 \log n) in the worst case$.
78+
This give a complexity of $O(n^2 + m)$, and for sorting the edges an additional $O(m \log n)$, which gives the complexity $O(n^2 \log n)$ in the worst case.
7979

8080
Below we consider two slightly different algorithms, one for dense and one for sparse graphs, both with a better complexity.
8181

0 commit comments

Comments
 (0)
0