Comparing MST-Prim's Algorithm with MST-Kruskal's Algorithm(์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ-ํ”„๋ฆผ ์•Œ๊ณ ๋ฆฌ์ฆ˜ vs. ํฌ๋Ÿฌ์Šค์ปฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜)

2011. 7. 24. 13:20ยทAlgorithms/The Greedy Approach

Time Complexity Comparison


The number of edges in a connected graph is

 

$$ n-1 \leq m \leq \frac{n(n-1)}{2} \approx n^2 $$

 

๐Ÿ‘‰ ์–ด๋–ค ๊ทธ๋ž˜ํ”„์˜ ์ •์ ์˜ ๊ฐœ์ˆ˜๋ฅผ n์ด๋ผ๊ณ  ํ•  ๋•Œ, ์ด์Œ์„  ๊ฐœ์ˆ˜(m)์˜ ๋ฒ”์œ„๋Š” n - 1๊ฐœ์—์„œ ๋ถ€ํ„ฐ n(n - 1)/2์ด๋‹ค. ์—ฌ๊ธฐ์„œ n(n-1)/2์€ 1๋ถ€ํ„ฐ n-1๊นŒ์ง€์˜ ํ•ฉ์ด๋‹ค.

 

For a graph whose number of edges m is near the low end of these limits (the graph is very sparse), Kruskal’s algorithm is $\Theta(nlgn)$ which means that Kruskal's algorithm should be faster. However, for a graph whose number of edges is near the high end (the graph is highly connected), Kruskal’s algorithm is $\Theta(n^2lgn)$, which means that Prim's algorithm should be faster.

Algorithm Technique Time Complexity
(์‹œ๊ฐ„๋ณต์žก๋„)
Sparse Graph
(ํฌ์†Œ ๊ทธ๋ž˜ํ”„)
Dense Graph
(๋ฐ€์ง‘ ๊ทธ๋ž˜ํ”„)
Prim's Algorithm $\Theta(n^2)$ $\Theta(n^2)$ $\Theta(n^2)$
Kruskal's Algorithm $\Theta(mlgm)$ and $\Theta(n^2lgn)$ $\Theta(mlgm)$ $\Theta(n^2lgn)$

 

๐Ÿ‘‰ ์ด์Œ์„ ์˜ ๊ฐœ์ˆ˜๊ฐ€ ํ•˜ํ•œ์„  ๊ทผ์ฒ˜(n - 1์— ๊ทผ์ ‘)์ธ ๊ฒฝ์šฐ ํฌ์†Œ ๊ทธ๋ž˜ํ”„(sparse graph)์ด๊ณ , ์ƒํ•œ์„  ๊ทผ์ฒ˜(n(n - 1)/2์— ๊ทผ์ ‘)์ธ ๊ฒฝ์šฐ๋Š” ๋ฐ€์ง‘ ๊ทธ๋ž˜ํ”„(dense graph) ์ด๋‹ค. 
์œ„์˜ ์„ฑ๋Šฅ ๋น„๊ตํ‘œ์—์„œ ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด, ํฌ์†Œ ๊ทธ๋ž˜ํ”„์˜ ๊ฒฝ์šฐ Kruskal ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์„ฑ๋Šฅ์ด, ๋ฐ€์ง‘ ๊ทธ๋ž˜ํ”„์˜ ๊ฒฝ์šฐ์—” Prim ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์„ฑ๋Šฅ์ด ํšจ์œจ์ ์ž„์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

 

'Algorithms > The Greedy Approach' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Dijkstra's Algorithm for Single-Source Shortest Paths(๋‹ค์ต์ŠคํŠธ๋ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜)  (0) 2011.07.24
Minimum Spanning Trees - Kruskal's Algorithm(์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ-ํฌ๋Ÿฌ์Šค์ปฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜)  (0) 2011.07.21
Minimum Spanning Trees - Prim's Algorithm(์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ-ํ”„๋ฆผ ์•Œ๊ณ ๋ฆฌ์ฆ˜)  (0) 2011.07.20
Greedy Approach(ํƒ์š•์  ์ ‘๊ทผ)  (2) 2011.01.23
'Algorithms/The Greedy Approach' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
  • Dijkstra's Algorithm for Single-Source Shortest Paths(๋‹ค์ต์ŠคํŠธ๋ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜)
  • Minimum Spanning Trees - Kruskal's Algorithm(์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ-ํฌ๋Ÿฌ์Šค์ปฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜)
  • Minimum Spanning Trees - Prim's Algorithm(์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ-ํ”„๋ฆผ ์•Œ๊ณ ๋ฆฌ์ฆ˜)
  • Greedy Approach(ํƒ์š•์  ์ ‘๊ทผ)
Zakarum
Zakarum
  • Zakarum
    Zakr. _archives
    Zakarum
  • ์ „์ฒด
    ์˜ค๋Š˜
    ์–ด์ œ
    • Zakarum
      • Cogito, ergo sum
      • Algorithms
        • Eff, Anal, and Order
        • Divide-and-Conquer
        • Dynamic Programming
        • The Greedy Approach
        • Backtracking
        • Branch-and-Bound
      • Et Cetera
        • Job-seeking
      • Not Public
        • MBA
        • Finance
        • 2.3. Civil•Commercial Law
        • 2.2. Credit Analysis (Basic..
        • 2.4. Foreign Exchange
        • 2.1. Accounting Principles ..
        • ITSM
        • Theory of NP
  • ๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

    • ํ™ˆ
    • ํƒœ๊ทธ
    • ๋ฐฉ๋ช…๋ก
    • ๊ธ€์“ฐ๊ธฐ
  • ๋งํฌ

  • ๊ณต์ง€์‚ฌํ•ญ

  • ์ธ๊ธฐ ๊ธ€

  • ํƒœ๊ทธ

    ๋ฒ ํŠธ๋‚จ์—ฌํ–‰
    ๋ถ„ํ• ์ •๋ณต๋ฒ•
    ํƒ์š• ์•Œ๊ณ ๋ฆฌ์ฆ˜
    ์†Œํ”„ํŠธ์›จ์–ด๊ณตํ•™
    p-np problem
    ITIL
    ๋Œ€๋งŒ์—ฌํ–‰
    ๋ฏผ์ƒ๋ฒ•๊ธฐ์ดˆ1
    ๋ฏธ๊ตญ์—ฌํ–‰
    ์•Œ๊ณ ๋ฆฌ์ฆ˜
    0-1 ๋ฐฐ๋‚ญ ๋ฌธ์ œ
    os concept
    ๋„คํŠธ์›Œํฌ
    ๋ถ„๊ธฐํ•œ์ •๋ฒ•
    ์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ
    process scheduling
    ์ผ๋ณธ์—ฌํ–‰
    ๋ฐฑํŠธ๋ž˜ํ‚น
    ๋™์ ๊ณ„ํš๋ฒ•
    ์žฌ๋ฌดํšŒ๊ณ„
    ์‹ ์šฉ๋ถ„์„๊ธฐ์ดˆ
    ์ดํƒˆ๋ฆฌ์•„์—ฌํ–‰
    ํšŒ๊ณ„์›๋ฆฌ๊ธฐ์ดˆ1
    ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ
    ํšŒ๊ณ„์›๋ฆฌ๊ธฐ์ดˆ2
    SNU MBA
    process management
    ์™ธ๊ตญํ™˜
    ๋ฏผ์ƒ๋ฒ•๊ธฐ์ดˆ3
    ๊ธˆ์œตIT ์ฑ„์šฉ์ •๋ณด
  • ์ตœ๊ทผ ๋Œ“๊ธ€

  • ์ตœ๊ทผ ๊ธ€

  • hELLOยท Designed By์ •์ƒ์šฐ.v4.10.5
Zakarum
Comparing MST-Prim's Algorithm with MST-Kruskal's Algorithm(์ตœ์†Œ์‹ ์žฅํŠธ๋ฆฌ-ํ”„๋ฆผ ์•Œ๊ณ ๋ฆฌ์ฆ˜ vs. ํฌ๋Ÿฌ์Šค์ปฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜)
์ƒ๋‹จ์œผ๋กœ

ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”