Binary Search Tree๋?
๐ ๊ฐ๋
Binary Search Tree(BST)๋ ํจ์จ์ ์ธ ํ์์ ์ํ ๋ฐ์ดํฐ ์ ์ฅ ๋ฐฉ๋ฒ์ด๋ค.
๐ ๊ท์น
- ๋ ธ๋์ ์ ์ฅ๋๋ ํค๋ ์ ์ผํ๋ค.
- ๋ถ๋ชจ์ ํค ๊ฐ์ด ์ผ์ชฝ ์์ ๋ ธ๋์ ํค ๊ฐ๋ณด๋ค ํฌ๋ค.
- ๋ถ๋ชจ์ ํค ๊ฐ์ด ์ค๋ฅธ์ชฝ ์์ ๋ ธ๋์ ํค ๊ฐ๋ณด๋ค ์๋ค.
- ์ผ์ชฝ๊ณผ ์ค๋ฅธ์ชฝ ์๋ธํธ๋ฆฌ๋ BST์ด๋ค.
๐ ์ฅ๋จ์
์ฅ์
ํ์ ์ฐ์ฐ ์๊ฐ๋ณต์ก๋๊ฐ O(log N)์ด๋ค. (๋ช
ํํ ๋งํ๋ฉด O(h))
๋จ์
ํธํฅ ํธ๋ฆฌ์ ๊ฒฝ์ฐ ์ ์ฅ ์์์ ๋ฐ๋ผ์ ํ ์ชฝ์ผ๋ก๋ง ๋
ธ๋๊ฐ ์ถ๊ฐ๋๋ ๊ฒฝ์ฐ๊ฐ ๋ฐ์ํ๋ค.
์ต์
์ ๊ฒฝ์ฐ๋ ํ์ ์๊ฐ๋ณต์ก๋๊ฐ O(N)์ด๋ค.
๋ฐฐ์ด๋ณด๋ค ๋ง์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ค.

Leetcode ๋ฌธ์ ๋ฅผ ํตํ BST ๊ตฌํ
BST๋ฅผ ์ง์ ๊ตฌํํ๋ ๊ฒ์ด ๋์์ด ๋ ๊ฒ์ด๋ผ ์๊ฐํ์ฌ ์๋ ๋ฌธ์ ๋ฅผ ํ์ด๋ณด์๋ค.
1. ํ์: https://leetcode.com/problems/search-in-a-binary-search-tree/
Search in a Binary Search Tree - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
2. ์ฝ์ : https://leetcode.com/problems/insert-into-a-binary-search-tree/
Insert into a Binary Search Tree - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
3. ์ญ์ : https://leetcode.com/problems/delete-node-in-a-bst/
Delete Node in a BST - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
๐ ํ์ด
1. ํ์
2. ์ฝ์
3. ์ญ์
'Engineering ๐ป > Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [์๊ณ ๋ฆฌ์ฆ] ๋ค์ด๋๋ฏน ํ๋ก๊ทธ๋๋ฐ (feat. Leetcode) (0) | 2022.02.06 |
|---|---|
| [์๋ฃ๊ตฌ์กฐ] ํ (Heaps) (0) | 2022.02.05 |
| [Leetcode/Python] 5. Longest Palindromic Substring (0) | 2022.01.12 |
| [Leetcode/Python] 48. Rotate Image (0) | 2022.01.12 |
| [Leetcode/Python] 15. 3sum (0) | 2022.01.11 |