0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

木構造

Posted at

木構造

階層の上位から下位に節点をたどることによって、データを取り出すことができるデータ構造。
Tree.png
○の部分は節(ノード)、節と節を繋いだ「—」の部分は枝(ブランチ)、最上位の節は根(ルート)、最下位の節は葉(リーフ)という。
また、上位の節を、下位の節をといい、節にぶら下がっている部分を部分木、左側を左部分木、右側を右部分木という。

2分木の種類

全ての枝の分岐が二つ以下の木構造。

完全2分木

根から葉までの深さが全て等しい2分木のこと。
※深さが一つだけ深い葉があり、木の左側から詰められているものも完全二分木とする。
ALDS1_9_A_1.png
20190226201354.png

2分探索木

各節において「左の子<親<右の子」という関係をもった2分木のこと。
col_tree0.png

ヒープ木

各節において、「親>子」「子>親」という関係をもった完全二分木。「子>親」の時、根の値が最小値となる。「親>子」の時、根の値が最大値となる。
Binary_heap_indexing.png

逆ポーランド記法(後置記法)

2分木を使って算術式を表記する方法の一つで、節に演算子、葉に被演算数を配置。
「左部分木」->「右部分木」->「節点」の順に取り出す。
002.png

B木

枝の分岐が二つ以上あり、データ挿入時は根から葉までの深さが同じになるように分割させる。
B+木は、葉のみにデータを持たせる

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?