Skip to content

Commit

Permalink
chore: Union-Find, 正準表現
Browse files Browse the repository at this point in the history
  • Loading branch information
xhiroga committed May 17, 2024
1 parent 5170192 commit aed35da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@

- nビットの論理ゲートは、1ビットの論理ゲートの内部を複製しただけなので、省略しました。
- 多入力マルチプレクサ、多入力デマルチプレクサも省略しました。

### 正準表現(Canonical Representation)

ブール関数を表す方法として、真理値表ではなくブール式(例: $f(A,B,C)=(A∧B)∨(¬A∧C)$)がある。

中でも、特定のルールに従ったブール式を正準表現と呼ぶ。([コンピュータシステムの理論と実装](https://amzn.to/4dJ5RDS)では正準表現と訳されているが、ググってみた感じ訳語が定まっていないようだ)

ブール式が正準表現である場合、それは積和標準形(Sum of Products, SOP)か和積標準形(Product of Sums, POS)のいずれかの形式をとる。
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,27 @@

### 計数ソート

[計数ソート | アルゴリズムビジュアル大事典
](https://yutaka-watanobe.github.io/star-aida/1.0/algorithms/counting_sort/print.html)を参照。
[計数ソート | アルゴリズムビジュアル大事典](https://yutaka-watanobe.github.io/star-aida/1.0/algorithms/counting_sort/print.html)を参照。

## 10章 ヒープ

- 最小ヒープは、親が子よりも小さく、根が最小になるヒープ。単にヒープといえば最小ヒープ。
- 最大ヒープはその逆となる。

## 14章 高度なデータ構造

### Union-Find

互いに素な集合がある時に、ある2つの要素が同じ集合に属しているか?を調べることをUnion-Findという。

集合を木構造で表したとき、同じ集合に属しているか?を調べるのは根を求めることに等しく、計算量が$O(N)$となりえる。

しかし、union by rank を行うことで$O(log N) に、さらに経路圧縮を行うことで$O(α(N))$となる。$α(N)$はアッカーマンの逆関数と呼ばれ、増加がとても遅いことで知られる。[^Union-Find]

- union by rank: 2つの木を合体させるとき、背の高い木に背の低い木をつなげる
- 経路圧縮: find処理時、中間節点を全て根に繋ぎなおす

[^Union-Find]: [Union-Find の 2 つの工夫](https://algo-method.com/descriptions/133)

## 参考

Expand Down

0 comments on commit aed35da

Please sign in to comment.