Skip to content

Commit

Permalink
update css class
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueHorn07 committed Jan 3, 2025
1 parent 51e3981 commit b3fce98
Show file tree
Hide file tree
Showing 120 changed files with 306 additions and 283 deletions.
2 changes: 1 addition & 1 deletion _pages/categories/computer-vision.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toc_sticky: true

<br>

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

[๋ชฉ์ฐจ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $a$, $b$, $c$์— ๋Œ€ํ•œ ๊ฐ’๋งŒ ์•ˆ๋‹ค๋ฉด, ๊ณ„์‚ฐ ๋ณต์žก๋„๋ฅผ ๋ฐ”๋กœ ์–ป์„ ์ˆ˜

<span class="statement-title">proof.</span><br>

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

At $k$-th level, we get $a_k$ subproblems of size $n/b^k$. Also we should consider fixed cost $O(n^c)$ too. At $k$-th level, the size of problem is $n/b^k$, so fixed cost is $O\left(\left(n/b^k\right)^c\right)$.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ $$

\<Master Theorem\>์„ ์ ์šฉํ•˜๊ธฐ ์ „์— ์žฌ๊ท€๋ฅผ ์ด์šฉํ•œ \<Multiplication Algorithm\>์ด ์–ด๋–ป๊ฒŒ ๋™์ž‘ํ•˜๋Š”์ง€๋ถ€ํ„ฐ ์ฝ”๋“œ-๋ ˆ๋ฒจ์—์„œ ์‚ดํŽด๋ณด์ž.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

function **multiply**($x$, $y$)<br/>
Input: Two $n$-bit integers $x$ and $y$<br/>
Expand Down
4 changes: 2 additions & 2 deletions _posts/computer-science/algorithm/2021-02-27-merge-sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Merge Sort๋Š” \<๋ถ„ํ•  ์ •๋ณต\>์„ ์ •๋ง ์ถฉ์‹คํžˆ ์ˆ˜ํ–‰ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด

Merge Sort๋Š” ๊ธฐ๋Šฅ์ ์œผ๋กœ ๋ดค์„ ๋•Œ, "**Merge Sort**"์™€ "**Merge**" ๋‘ ๊ฐ€์ง€ ์ž‘์—…๋งŒ ์ˆ˜ํ–‰ํ•˜๋ฉด ๋œ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

function: **mergesort**($a[1...n]$)

Expand All @@ -39,7 +39,7 @@ function: **mergesort**($a[1...n]$)

</div>

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

function: **merge**($x[1...k]$, $y[1...l]$)

Expand Down
8 changes: 4 additions & 4 deletions _posts/computer-science/algorithm/2021-03-12-dfs-and-bfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ An undirected graph is \<**connected**\> if for every pair of nodes $u$ and $v$,

\<DFS\>๋ฅผ ์ˆ˜๋„ ์ฝ”๋“œ๋กœ ํ‘œํ˜„ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

function: **explore**($G$, $v$)<br/>
Input: $G=(V, E)$ is a graph; $v \in V$<br/>
Expand All @@ -55,7 +55,7 @@ Output: for all nodes $u$ reachable from $v$, **visited**($u$) is set to $true$.

ํ•˜์ง€๋งŒ \<DFS\> ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์ •๋ง๋กœ $v$์—์„œ reachableํ•œ ๋ชจ๋“  ๋…ธ๋“œ๋ฅผ ๋ฐฉ๋ฌธํ•œ๋‹ค๊ณ  ์–ด๋–ป๊ฒŒ ๋ณด์žฅํ•  ์ˆ˜ ์žˆ์„๊นŒ? "\<DFS\> ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์‹œ์ž‘ ๋…ธ๋“œ $v$์—์„œ ๋„๋‹ฌํ•  ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๋…ธ๋“œ๋ฅผ ๋ฐฉ๋ฌธํ•œ๋‹ค."๋Š” ๋ช…์ œ๋ฅผ ์ฆ๋ช…ํ•ด๋ณด์ž!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

<div class="img-wrapper">
<img src="{{ "/images/computer-science/algorithm/dfs-1.jpg" | relative_url }}" width="280px">
Expand All @@ -79,7 +79,7 @@ $z$์— ๋ฐฉ๋ฌธํ–ˆ์œผ๋ฉด, **explore** ํ•จ์ˆ˜์—์„œ ์ธ์ ‘ํ•œ ๋ชจ๋“  ๋…ธ๋“œ๋ฅผ ๋ฐฉ

์ด๋ฒˆ์—๋Š” \<DFS\> ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„๋ฅผ ๊ณ„์‚ฐํ•ด๋ณด์ž! ๊ทธ๋ž˜ํ”„๋ฅผ \<์ธ์ ‘ ํ–‰๋ ฌ\>๊ณผ \<์ธ์ ‘ ๋ฆฌ์ŠคํŠธ\>๋กœ ํ‘œํ˜„ํ–ˆ๋Š๋ƒ์— ๋”ฐ๋ผ์„œ ์‹œ๊ฐ„ ๋ณต์žก๋„๊ฐ€ ๋‹ค๋ฅธ๋ฐ, ๋ณธ์ธ์ด ์ฃผ๋กœ \<์ธ์ ‘ ๋ฆฌ์ŠคํŠธ\> ๋ฐฉ์‹์œผ๋กœ ๊ทธ๋ž˜ํ”„๋ฅผ ์ƒ๊ฐํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์—ฌ๊ธฐ์„œ๋Š” \<์ธ์ ‘ ๋ฆฌ์ŠคํŠธ\>์˜ ๊ฒฝ์šฐ๋ฅผ ์‚ดํŽด๋ณด๊ฒ ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

๊ทธ๋ž˜ํ”„ $G=(V, E)$์— ๋Œ€ํ•ด ๋ชจ๋“  ์ •์ ์„ ๋ฐฉ๋ฌธํ•œ๋‹ค๊ณ  ํ•˜๋ฉด, **explore**๋Š” ์ด $V$๋ฒˆ ํ˜ธ์ถœ๋œ๋‹ค. ์ด๋•Œ, ๊ฐ **explore**์—์„œ ๋…ธ๋“œ $v$์˜ $\deg$ ๋งŒํผ **for** ๋ฌธ์„ ๋Œ๋ฆฌ๋ฏ€๋กœ \<DFS\> ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์ข…๋ฃŒ๋œ ์‹œ์ ์—์„œ ๋ณด๋ฉด, $\displaystyle \sum_{v} \deg(v)$ ๋งŒํผ iteration์„ ์ˆ˜ํ–‰ํ•œ ๊ฒƒ์ด ๋œ๋‹ค. ์ด๋•Œ, $\displaystyle \sum_{v} \deg(v) = 2 \times E$์ด๋‹ค.

Expand Down Expand Up @@ -108,7 +108,7 @@ $\blacksquare$

\<BFS\>๋ฅผ ์ˆ˜๋„ ์ฝ”๋“œ๋กœ ํ‘œํ˜„ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

function: **bfs**($G$, $s$)<br/>
Input: $G=(V, E)$ is a graph; $s \in V$<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ categories: ["Algorithm"]

BFS์˜ ์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด \<alarm clock algorithm\>์„ ๋„์ž…ํ•  ์ˆ˜ ์žˆ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

1\. Set $\texttt{alaram}(s)=0$, and for all other nodes $v$, set $\texttt{alarm}(v)=\infty$.

Expand All @@ -34,7 +34,7 @@ BFS์˜ ์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด \<alarm clock algorithm\>์„ ๋„์ž…

์œ„์—์„œ ์ œ์‹œ๋œ \<alarm clock algorithm\>์€ \<**์šฐ์„ ์ˆœ์œ„ ํ; priority queue**\>๋ฅผ ํ†ตํ•ด ์‰ฝ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Algorithm: **dijkstra**($G$, $\ell$, $s$)<br/>
<small>โ€ป ์ฃผ์˜: ๊ทธ๋ž˜ํ”„ $G$์˜ ๋ชจ๋“  edge๋Š” positive edge์—ฌ์•ผ ํ•œ๋‹ค.</small>
Expand Down Expand Up @@ -76,7 +76,7 @@ $H = \texttt{makequeue}(V)$

์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์ ‘๊ทผํ•˜์—ฌ ์•ž์—์„œ ์†Œ๊ฐœํ•œ ๋ฐฉ์‹์˜ ๋™์น˜์ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ œ์‹œํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Algorithm: **dijkstra**($G$, $\ell$, $s$)<br/>

Expand Down
4 changes: 2 additions & 2 deletions _posts/computer-science/algorithm/2021-04-18-Bellman-Ford.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if dist(v) > dist(u) + w(u, v):
<span class="statement-title">*Proof*.</span><br>
<div class="math-statement" markdown="1">
<div class="proof" markdown="1">
Consider the shortest path $\pi = su_1u_2u_3\cdots u_k t$ from $s$ to $t$.
Expand All @@ -90,7 +90,7 @@ Then every subpath $\pi_i = su_1\cdots u_i$ is
<span class="statement-title">Algorithm.</span><br>
<div class="math-statement" markdown="1">
<div class="proof" markdown="1">
์‹œ์ž‘์  $s$๋Š” $\texttt{dist}(s)=0$์œผ๋กœ, ๋‚˜๋จธ์ง€ ๋…ธ๋“œ๋Š” ๋ชจ๋‘ `INF`๋กœ ์ดˆ๊ธฐํ™”ํ•œ๋‹ค. ์ด์ œ ์‹œ์ž‘์  $s$์™€ ์—ฐ๊ฒฐ๋œ ๋…ธ๋“œ๋“ค์„ ์‚ดํŽด๋ณด์ž. *See node $u_i$ s.t. $(s, u_i) \in E$*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ A directed graph is a DAG iff it has a topological ordering.

์ด๋ ‡๊ฒŒ DAG๋ฅผ topological order๋กœ linearization ํ–ˆ๋‹ค๋ฉด, ์šฐ๋ฆฌ๋Š” DAG ์œ„์—์„œ์˜ shortest path๋ฅผ ์‰ฝ๊ฒŒ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Linearize $G$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Then $X \cup \\{ e \\}$ is part of some MST.

<span class="statement-title">*Proof*.</span><br>

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

<div class="img-wrapper">
<img src="{{ "/images/computer-science/algorithm/cut-property-2.png" | relative_url }}" width="200px">
Expand All @@ -74,7 +74,7 @@ Then, $T'$ is a spanning tree with $\texttt{cost}(T') \le \texttt{cost}(T)$ (์™œ

\<Kruskal Algorithm\>์€ \<**set**\> ์ž๋ฃŒํ˜•์„ ์‚ฌ์šฉํ•ด ์‰ฝ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค! ๐Ÿคฉ

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Algorithm: **Kruskal**($G$, $w$)<br/>
<small>($G = (V, E)$ is a connected undirected graph with edge weights $w_e$.)</small>
Expand Down Expand Up @@ -120,7 +120,7 @@ $\texttt{makeset}$, $\texttt{find}$, $\texttt{union}$ ์—ฐ์‚ฐ์— ๋Œ€ํ•œ ์‹œ๊ฐ„๋ณต

\<Prim's Algorithm\>์€ ๊ทธ๋ž˜ํ”„ $G$์—์„œ ๊ฐ€์žฅ lightํ•œ edge๋ฅผ ์„ ํƒํ•˜๋ฉฐ, intermediate MST $X$๋ฅผ grow ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ์ด๋•Œ, ํฌ๋ฃจ์Šค์ปฌ ๋•Œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์„ ํƒํ•œ edge๋กœ ์ธํ•ด cycle์ด ํ˜•์„ฑ๋˜์–ด์„œ๋Š” ์•ˆ ๋œ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Algorithm: **Prime**($G$, $w$)<br/>
<small>($G = (V, E)$ is a connected undirected graph with edge weights $w_e$.)</small>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $$

์•„์ด๋””์–ด๋Š” ๊ฐ„๋‹จํ•˜๋‹ค. ๋‘ prefix์— ๋Œ€ํ•ด, <span class="half_HL">๋งˆ์ง€๋ง‰ ๋ฌธ์ž๊ฐ€ ๊ณต๋ฐฑ์ผ ๋•Œ์˜ ๋‘ ๊ฒฝ์šฐ</span>์™€ <span class="half_HL">๋งˆ์ง€๋ง‰ ๋ฌธ์ž๋ฅผ ๋งž์ท„์„ ๋•Œ์˜ ๊ฒฝ์šฐ</span>๋ฅผ ์ข…ํ•ฉํ•ด ์ตœ์†Œ edit distance์˜ ๊ฒฝ์šฐ๋ฅผ ์ทจํ•˜๋Š” ์•„์ด๋””์–ด๋‹ค!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

<span style="color: grey">// initialization</span><br/>
**for** $i=0, 1, 2, \dots, m$<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $n$๊ฐœ์˜ ์ˆ˜์—…์ด ์ฃผ์–ด์กŒ๊ณ , ๊ฐ ์ˆ˜์—… $j$๋Š” $[s_j, f_j]$์˜ start/finish

์œ„์˜ ๋ฌธ์ œ ์—ญ์‹œ Greedy Algorithm์œผ๋กœ ๊ฐ„๋‹จํžˆ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค!!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Algorithm: **Interval-Partition**($S$)<br/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Directed Graph๊ฐ€ ๊ทธ๋ ค์กŒ๋‹ค!! ๊ทธ๋Ÿฐ๋ฐ, ์ข€ ์ต์ˆ™ํ•˜์ง€ ์•Š์€๊ฐ€? ๋ฐ”๋กœ *



<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

**for** $j=1, 2, \dots, n$<br/>
&emsp;&emsp;$L(j) = 1 + \max \\{ L(i) : (i, j) \in E \\}$
Expand Down
4 changes: 2 additions & 2 deletions _posts/computer-science/algorithm/2021-04-30-kanpsack.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ps) "knapsack"์˜ ๋œป์€ "ํ•˜์ดํ‚น ๋”ฐ์œ„์˜ ์•„์ฃผ ๊ฐ„๋‹จํ•œ ์Šคํฌ์ธ ์— ์‚ฌ

์ฒซ๋ฒˆ์งธ ๊ฒฝ์šฐ๋Š” ์•„์ดํ…œ์˜ ์ˆ˜๊ฐ€ **๋ฌดํ•œํžˆ ๋งŽ์€**<small>(unlimited quantities)</small> ๊ฒฝ์šฐ๋ฅผ ๋งํ•œ๋‹ค. ์ด๋•Œ, ๋ƒ…์ƒ‰ ๋ฌธ์ œ๋Š” capacity๋ฅผ 1๋ถ€ํ„ฐ ์˜ฌ๋ ค๊ฐ€๋ฉฐ ์ด์ „์— ๊ณ„์‚ฐํ•œ ๋ƒ…์ƒ‰ DP์˜ ๊ฐ’์— ์•„์ดํ…œ์„ ์ถ”๊ฐ€ํ–ˆ์„ ๋•Œ, ๊ฐ€์žฅ ํฐ value๋ฅผ ์œ ๋„ํ•˜๋Š” **์กฐํ•ฉ**์„ ์ฐพ๋Š” ๋ฌธ์ œ๊ฐ€ ๋œ๋‹ค. ์ผ๋‹จ ์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด์ž!!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Initialize all $K(j) = 0$.

Expand Down Expand Up @@ -66,7 +66,7 @@ $$

์œ„์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ฝ”๋“œ๋กœ ์˜ฎ๊ธฐ๋Š” ๊ฒƒ์€ ๊ฒฐ๊ตญ **2์ฐจ์› DP ๋ฌธ์ œ**๋ฅผ ํ‘ธ๋Š” ๊ฒƒ๊ณผ ๊ฐ™๋‹ค! ์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด์ž!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Initialize all $K(0, j) = 0$ and all $K(w, 0) = 0$.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DP์—์„œ๋Š” ์ด ๋ฌธ์ œ๋ฅผ ์•„๋ž˜์™€ ๊ฐ™์ด ์ ‘๊ทผํ•œ๋‹ค.

- $C(i, j)$ = min cost of multiplying $A_i \times \cdots A_j$

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

**for** $\ell = 1, 2, \dots, n$<br/>
&emsp;&emsp;**for** $i=1, 2, \dots, n - \ell + 1$<br/>
Expand All @@ -84,7 +84,7 @@ DP์—์„œ๋Š” ์ด ๋ฌธ์ œ๋ฅผ ์•„๋ž˜์™€ ๊ฐ™์ด ์ ‘๊ทผํ•œ๋‹ค.

๋งŒ์•ฝ best-split ์ˆœ์„œ๋ฅผ ๊ธฐ๋กํ•ด ์‹ค์ œ binary opr tree๋ฅผ ๊ตฌ์„ฑํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, $C(i, j)$๋ฅผ ๊ฐฑ์‹ ํ•˜๋Š” ๊ณผ์ •์—์„œ ์–ธ์ œ minimum์„ ๋‹ฌ์„ฑํ•˜๋Š”์ง€ ๊ธฐ๋กํ•ด๋‘๋ฉด ๋œ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;**if** $\texttt{cost} < C(i, j)$<br/>
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;$C(i, j) = \texttt{cost}$<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $\texttt{sink}$๋Š” ์ž์‹ ๋…ธ๋“œ๋ณด๋‹ค ์ž‘์€ key๋ฅผ ๊ฐ€์ง„ ๋ถ€๋ชจ ๋…ธ๋“œ๊ฐ€ ์ž
- $\texttt{insert}$: $O(\log_d N)$
- $\texttt{deleteMin}$: $O(d \log_d N)$

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

<b>\* $\texttt{deleteMin}$ in d-ary Heap</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $$

$O(n^3)$ ์ˆ˜์ค€์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์•„์ง ๋งŽ์ด ๋Š๋ฆฌ๋‹ค. \<Graham's Scan\>์€ points๋ฅผ ์ •๋ ฌํ•˜๊ณ , ๋˜ ๋ช‡๊ฐ€์ง€ ๊ทœ์น™์„ ํ†ตํ•ด $O(n^3)$๋ณด๋‹ค ํ›จ์”ฌ ๋น ๋ฅธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ œ์‹œํ•œ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

<span class="statement-title">Algorithm.</span><br>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int fibo(n) {
๊ทธ๋Ÿฌ๋‚˜ ์œ„์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ผ์„ ๋•Œ์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„๋Š” exponential ํ•˜๋‹ค. ๐Ÿคฆโ€โ™‚๏ธ
<div class="math-statement" markdown="1">
<div class="proof" markdown="1">
`fibo()`์— ์˜ํ•ด ์ƒ์„ฑ๋˜๋Š” recursion tree๋ฅผ ์ƒ๊ฐํ•ด๋ณด์ž. ์ด๋•Œ, tree์˜ leaf๋Š” ํ•ญ์ƒ 1์„ ๋ฆฌํ„ดํ•ด์ฃผ๊ณ  ์ด์— ๋”ฐ๋ผ `fibo(n)`์˜ ๊ฐ’์€ ๋‹จ์ˆœํžˆ recursion tree์˜ leaves ์ˆ˜๋กœ ์œ ๋„ํ•  ์ˆ˜ ์žˆ๋‹ค.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ categories: ["Algorithm"]

์ด๋ฅผ ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ํ‘œํ˜„ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

// initialize<br/>
**for all** $(i, j) \in E$<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ categories: ["Algorithm"]

์ด ๋ฌธ์ œ๋Š” \<DP\> ๊ธฐ๋ฒ•์„ ์‚ฌ์šฉํ•ด $k$๋ฅผ ์ ์ง„์ ์œผ๋กœ ์ฆ๊ฐ€์‹œํ‚ค๋ฉฐ ํ’€ ์ˆ˜ ์žˆ๋‹ค. ์‹œ์ž‘๋…ธ๋“œ $s$์—์„œ ๊ฐ ๋…ธ๋“œ $v$๊นŒ์ง€ $k$๊ฐœ์˜ edge๋ฅผ ๊ฑฐ์ณค์„ ๋•Œ, ์ฆ‰ $k$-hop์„ ํ–ˆ์„ ๋•Œ์˜ shortest cost๋ฅผ `dist[v][k]`์— ์ €์žฅํ•˜๋ฉด ๋œ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Let $\text{dist}(v, i)$ be the shortest path from $s$ to $v$ that uses $i$ edges.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ long long shortestPath(vector<int> &path, vector<bool> &visited, long long curre
\<TSP\>๋ฅผ \<DP\>๋กœ ํ’€๊ธฐ ์œ„ํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ๋ผˆ๋Œ€๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
<div class="math-statement" markdown="1">
<div class="proof" markdown="1">
Let $C(j, S)$ the length of shortest path when visit $j$ at last and visit each node in $S$ exactly once.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Given a graph $G = (V, E)$, a subset $S \subset V$ is an \<**independent set**\>

๋จผ์ € ์ฒซ ๋ฒˆ์งธ ๊ฒฝ์šฐ๋Š” ํŠธ๋ฆฌ์˜ ๋…ธ๋“œ์— ๊ฐ€์ค‘์น˜๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ๋‹ค. ๋ฌธ์ œ๋ฅผ ๋ฌ˜์‚ฌํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

๋‹น์‹ ์€ ํšŒ์‚ฌ ํŒŒํ‹ฐ๋ฅผ ์ฃผ์ตœํ•˜๋ ค ํ•œ๋‹ค. ์ตœ๋Œ€ํ•œ ๋งŽ์€ ์‚ฌ๋žŒ์„ ์ดˆ๋Œ€ํ•˜๋ ค ํ•˜์ง€๋งŒ ๊ฐ๊ฐ์˜ ์‚ฌ๋žŒ๋“ค์€ ๋ฐ”๋กœ ์ง์† ์ƒ์‚ฌ๊ฐ€ ํŒŒํ‹ฐ์— ์˜ฌ ๊ฒฝ์šฐ ํŒŒํ‹ฐ์— ์˜ค์ง€ ์•Š๋Š”๋‹ค.

Expand All @@ -41,7 +41,7 @@ Given a graph $G = (V, E)$, a subset $S \subset V$ is an \<**independent set**\>

์ด ๊ฒฝ์šฐ, greedy ํ•˜๊ฒŒ ์ ‘๊ทผํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

**while** $T$ is not empty:<br/>
&emsp;&emsp; take all the leaves to the solution.<br/>
Expand All @@ -54,7 +54,7 @@ Given a graph $G = (V, E)$, a subset $S \subset V$ is an \<**independent set**\>

๋‘ ๋ฒˆ์งธ ๊ฒฝ์šฐ๋Š” ํŠธ๋ฆฌ์˜ ๋…ธ๋“œ์— ๊ฐ€์ค‘์น˜๊ฐ€ ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ๋‹ค. ๋ฌธ์ œ๋ฅผ ๋ฌ˜์‚ฌํ•˜๋ฉด,

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

์œ„์˜ ๋ฌธ์ œ์™€ ์ƒํ™ฉ์€ ๋˜‘๊ฐ™์œผ๋‚˜ ํŒŒํ‹ฐ์— ์˜ค๋Š” ์‚ฌ๋žŒ๋งˆ๋‹ค ๋งค๋ ฅ์ ์ธ ์ •๋„๊ฐ€ ์žˆ์–ด์„œ ์ด ๋งค๋ ฅ๋„์˜ ๅˆ์„ ์ตœ๋Œ€๋กœ ํ•˜๊ณ ์ž ํ•œ๋‹ค.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A set of $n$ jobs, job $j$ starts at $s_j$, finishes at $f_j$ and has weight $w_

$DP[j]$๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋Š” ๊ทœ์น™์—๋Š” 2๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">


1\. select job $j$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $$

\<Networ Flow\> ๋ฌธ์ œ๋Š” ๊ธฐ์กด์˜ Graph $G$์—์„œ \<**Residual Network**\>๋ผ๋Š” ๊ทธ๋ž˜ํ”„๋ฅผ ๊ตฌ์ถ•(construction) ํ•˜๋ฉด์„œ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค! ๐Ÿ˜‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ํ•œ๋ฒˆ์— ์ดํ•ด ๋˜์ง€๋Š” ์•Š์œผ๋‹ˆ ์ฃผ์˜ ๊นŠ๊ฒŒ ์‚ดํŽด๋ณด์ž!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Find an $s-t$ path whose edges $(u, v)$ can be of two types:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ categories: ["Algorithm"]

[๋ฐฑ์ค€ 1933๋ฒˆ: ์Šค์นด์ด๋ผ์ธ](https://www.acmicpc.net/problem/1933) ๋ฌธ์ œ๋ฅผ ๋‹ค๋ฃจ๋Š” ํฌ์ŠคํŠธ์ž…๋‹ˆ๋‹ค ๐Ÿ™Œ

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Given n rectangular buildings in a 2-dimensional city, computes the **skyline** of these buildings, eliminating hidden lines. The main task is to view buildings from a side and remove all sections that are not visible.

Expand Down Expand Up @@ -71,7 +71,7 @@ A **skyline** is a collection of rectangular strips. A rectangular strip is repr

๊ฐ key point์˜ overlap ๋˜๋Š” tallest building์„ ์ฐพ๊ธฐ ์œ„ํ•ด `building` ๋ฐฐ์—ด์„ ์ˆœํšŒํ•œ๋‹ค: $O(n)$. ๋”ฐ๋ผ์„œ $n$๊ฐœ key point๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ $O(n)$ ๋งŒํผ์˜ ์—ฐ์‚ฐ์ด ํ•„์š”ํ•˜๋ฏ€๋กœ, Brute Force ๋ฐฉ์‹์€ $O(n^2)$์˜ ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๊ฐ–๋Š”๋‹ค.

<details class="math-statement" markdown="1">
<details class="proof" markdown="1">

<summary>Brute Force ํ’€์ด</summary>

Expand Down Expand Up @@ -177,7 +177,7 @@ vector<Coord> skyline(vector<Building> buildings) {
2๊ฐœ์˜ skyline ๋ฐฐ์—ด์„ mergeํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.
<div class="math-statement" markdown="1">
<div class="proof" markdown="1">
<div class="img-wrapper">
<img src="{{ "/images/computer-science/algorithm/skyline-problem-6.png" | relative_url }}" width="300px">
Expand Down Expand Up @@ -281,7 +281,7 @@ vector<Coord> merge(vector<Coord> left_side, vector<Coord> right_side) {

์ด ๊ฒฝ์šฐ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ํ•ด๊ฒฐํ•œ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

If `x` values of both key points are same, then choose the one with higher `y` value and advance key points for both skylines.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ categories: ["Algorithm"]

์‚ฌ์‹ค [Network Flow]({{"/2021/07/16/network-flow" | relative_url}}) ํฌ์ŠคํŠธ์—์„œ ์„ค๋ช…ํ•œ Max-Flow๋ฅผ ์ฐพ๋Š” ๋ฐฉ๋ฒ•์„ ์ฝ”๋“œ๋กœ ๊ตฌํ˜„ํ•œ ๊ฒƒ์— ๋ถˆ๊ณผํ•˜๋‹ค. ํฐ ๋ฒ”์ฃผ๋กœ ๋ดค์„ ๋•Œ๋Š” Brute Force Algorithm์— ์†ํ•œ๋‹ค.

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

1\. source์—์„œ sink๋กœ ๊ฐ€๋Š” ์œ ๋Ÿ‰์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๊ฒฝ๋กœ $p$๋ฅผ ํ•˜๋‚˜ ์ฐพ๋Š”๋‹ค. DFS ๋˜๋Š” BFS๋ฅผ ์ด์šฉํ•˜๋ฉด ๋œ๋‹ค.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ categories: ["Algorithm"]
<img src="{{ "/images/computer-science/algorithm/bipartite-matching-2.png" | relative_url }}" width="600px">
</div>

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

<span class="statement-title">Reduction to NF</span>

Expand All @@ -57,7 +57,7 @@ all capacities are 1, so an edge is used(= flow 1) or not.

๊ทธ๋ฆฌ๊ณ  reduction๋œ NF ๋ฌธ์ œ์—์„œ ์–ป๋Š” maximum total flow๊ฐ€ maximum matching์„ ์œ ๋„ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ฆ๋ช…ํ•ด๋ณด์ž!

<div class="math-statement" markdown="1">
<div class="proof" markdown="1">

Let $M$ be the set of edges used in the maximum flow of value $k$. Then $M$ is a matching because there is at most on edge in $M$ leaving a one person and entering a one job. (๋ฐ”๋กœ ์œ„์—์„œ ์–ธ๊ธ‰ํ•œ ์„ฑ์งˆ ๋•Œ๋ฌธ!) Moreover, $M$ consists of $k$ matching edges!

Expand Down
Loading

0 comments on commit b3fce98

Please sign in to comment.