๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ์žฅ์›์ต ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ
๐Ÿ’ป Computer Science/- Data Structure, Algorithm

[์ž๋ฃŒ ๊ตฌ์กฐ] - ํŠธ๋ฆฌ ์ž๋ฃŒ ๊ตฌ์กฐ (3)-์ด์ง„ ํŠธ๋ฆฌ์™€ ์ข…๋ฅ˜(์™„์ „, ํฌํ™”, ์™„๋ฒฝ, ๊ท ํ˜•) :: Binary Tree (Full, Complete, Perfect, Balanced)

by Wonit 2020. 6. 18.

์ด์ง„ ํŠธ๋ฆฌ๋Š” ์šฐ๋ฆฌ๊ฐ€ ์•ž์œผ๋กœ ๋งˆ์ฃผํ•˜๊ฒŒ๋  ํŠธ๋ฆฌ(Red-Black Tree, AVL Tree, Segment Tree)๋“ค์ค‘ ๊ฐ€์žฅ ์‰ฝ๊ณ  ์ž์ฃผ ์“ฐ์ด๋Š” ํŠธ๋ฆฌ์ด๋‹ค.

์ด์ง„ ํŠธ๋ฆฌ Binary Tree

์ด์ง„ ํŠธ๋ฆฌ๋Š” ๋…ธ๋“œ๊ฐ€ ์™ผ์ชฝ ์ž์‹๊ณผ ์˜ค๋ฅธ์ชฝ ์ž์‹์„ ๊ฐ–๋Š” ํŠธ๋ฆฌ์ด๋‹ค.

 

์ด ๋•Œ ์ค‘์š”ํ•œ ์ ์ด ์™ผ์ชฝ ์ž์‹๊ณผ ์˜ค๋ฅธ์ชฝ ์ž์‹์„ ํ•˜๋‚˜์”ฉ๋งŒ ๊ฐ€์ ธ์•ผ ์ด์ง„ ํŠธ๋ฆฌ๊ฐ€ ๋œ๋‹ค.

 

์ด๋Ÿฌํ•œ ์ด์ง„ ํŠธ๋ฆฌ๋Š” ์™ผ์ชฝ ์ž์‹๊ณผ ์˜ค๋ฅธ์ชฝ ์ž์‹์„ ๊ตฌ๋ถ„ํ•œ๋‹ค๋Š” ํŠน์ง•์ด ์žˆ๋Š”๋ฐ, ์šฐ๋ฆฌ๊ฐ€ ํŠธ๋ฆฌ์˜ ๊ฐœ๋…๊ณผ ์šฉ์–ด ์—์„œ ๋ฐฐ์› ๋“ฏ์ด ์˜ค๋ฅธ์ชฝ ์ž์‹์€ ์˜ค๋ฅธ์ชฝ ์„œ๋ธŒํŠธ๋ฆฌ๋ฅผ ๊ฐ–๊ณ  ์™ผ์ชฝ์€ ์™ผ์ชฝ ์„œ๋ธŒํŠธ๋ฆฌ๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.

์ถœ์ฒ˜ : https://coderkoo.tistory.com/9

์ด์ œ ์ด์ง„ ํŠธ๋ฆฌ์— ๋Œ€ํ•ด์„œ ์•Œ์•˜์œผ๋‹ˆ ๊ทธ ์ข…๋ฅ˜์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.

์ด์ง„ ํŠธ๋ฆฌ์˜ ์ข…๋ฅ˜

์ถœ์ฒ˜ : https://towardsdatascience.com/

์ด์ง„ ํŠธ๋ฆฌ์˜ ์ข…๋ฅ˜๋Š” ํฌ๊ฒŒ 5๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. ํ•œ๊ธ€๋กœ ๋ฒˆ์—ญํ•˜๋Š” ๊ณผ์ •์—์„œ ์—ฌ๋Ÿฌ ์ฐธ๊ณ  ์„œ์ ๋“ค์ด ์ž˜ ๋ชป ๋ฒˆ์—ญํ•˜์—ฌ ์ž˜ ๋ชป ์•Œ๊ฒŒ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์–ด์„œ ํ•„์ž๋Š” ์˜์–ด๋กœ ์„ค๋ช…ํ•˜๊ฒ ๋‹ค.

  • Full
  • Complete
  • Degenerate
  • Perfect
  • Balanced

Full Binary Tree

Full Bianry Tree๋Š” ๋ชจ๋“  ๋…ธ๋“œ์˜ ์ž์‹์ด 0์ด๊ฑฐ๋‚˜ 1์ธ ์ด์ง„ ํŠธ๋ฆฌ์ด๋‹ค.

Complete Binary Tree

Complete Binary Tree๋Š” ๋งˆ์ง€๋ง‰ ๋…ธ๋“œ๋ฅผ ์ œ์™ธํ•˜๊ณ  ๋ชจ๋“  ๋…ธ๋“œ์˜ ์ž์‹์ด 0์ด๋ฉฐ ๋งˆ์ง€๋ง‰ ๋ ˆ๋ฒจ์˜ ๋…ธ๋“œ๋Š” ์™ผ์ชฝ์— ์ฑ„์›Œ์ ธ ์žˆ๋Š” ํ˜•ํƒœ์ด๋‹ค.

Degenerate Binary Tree

Degenerate Binary Tree๋Š” ๋ชจ๋“  ๋ถ€๋ชจ ๋…ธ๋“œ๊ฐ€ ์™ผ์ชฝ์œผ๋กœ ์ž์‹์„ ๊ฐ–๋Š” ๊ฒฝ์šฐ์ด๋‹ค.

Perfect Binary Tree

Perfect Bianry Tree๋Š” ๋ชจ๋“  ๋…ธ๋“œ์˜ ์ž์‹์ด 0์ด๊ฑฐ๋‚˜ ์ฑ„์›Œ์ ธ ์žˆ๋Š” ํ˜•ํƒœ๋กœ ๋ฃจํŠธ ๋…ธ๋“œ๋ฅผ ๊ธฐ์ค€์ด๋กœ ์ขŒ ์šฐ๊ฐ€ ๊ท ํ˜•์ด ๋˜์–ด์•ผ ํ•œ๋‹ค.

Balanced Binary Tree

Balanced Binary Tree๋Š” ๋ชจ๋“  ๋…ธ๋“œ์˜ ์™ผ์ชฝ๊ณผ ์˜ค๋ฅธ์ชฝ ํ•˜์œ„ ํŠธ๋ฆฌ์˜ ๋†’์ด๊ฐ€ ์ตœ๋Œ€ 1๋งŒํผ ์ฐจ์ด๊ฐ€ ๋‚  ์ˆ˜ ์žˆ๋Š” ์ด์ง„ ํŠธ๋ฆฌ๋‹ค.

๋Œ“๊ธ€