[์ž๋ฃŒ๊ตฌ์กฐ] Binary Search Tree

2022. 2. 5. 00:21ยทEngineering/Algorithm

Binary Search Tree๋ž€?


๐Ÿ‘‰ ๊ฐœ๋…

Binary Search Tree(BST)๋Š” ํšจ์œจ์ ์ธ ํƒ์ƒ‰์„ ์œ„ํ•œ ๋ฐ์ดํ„ฐ ์ €์žฅ ๋ฐฉ๋ฒ•์ด๋‹ค. 

 

๐Ÿ‘‰ ๊ทœ์น™

  • ๋…ธ๋“œ์— ์ €์žฅ๋˜๋Š” ํ‚ค๋Š” ์œ ์ผํ•˜๋‹ค. 
  • ๋ถ€๋ชจ์˜ ํ‚ค ๊ฐ’์ด ์™ผ์ชฝ ์ž์‹ ๋…ธ๋“œ์˜ ํ‚ค ๊ฐ’๋ณด๋‹ค ํฌ๋‹ค. 
  • ๋ถ€๋ชจ์˜ ํ‚ค ๊ฐ’์ด ์˜ค๋ฅธ์ชฝ ์ž์‹ ๋…ธ๋“œ์˜ ํ‚ค ๊ฐ’๋ณด๋‹ค ์ž‘๋‹ค. 
  • ์™ผ์ชฝ๊ณผ ์˜ค๋ฅธ์ชฝ ์„œ๋ธŒํŠธ๋ฆฌ๋„ BST์ด๋‹ค. 

 

๐Ÿ‘‰ ์žฅ๋‹จ์ 

์žฅ์ 
ํƒ์ƒ‰ ์—ฐ์‚ฐ ์‹œ๊ฐ„๋ณต์žก๋„๊ฐ€ O(log N)์ด๋‹ค. (๋ช…ํ™•ํžˆ ๋งํ•˜๋ฉด O(h))

๋‹จ์  
ํŽธํ–ฅ ํŠธ๋ฆฌ์˜ ๊ฒฝ์šฐ ์ €์žฅ ์ˆœ์„œ์— ๋”ฐ๋ผ์„œ ํ•œ ์ชฝ์œผ๋กœ๋งŒ ๋…ธ๋“œ๊ฐ€ ์ถ”๊ฐ€๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.
์ตœ์•…์˜ ๊ฒฝ์šฐ๋Š” ํƒ์ƒ‰ ์‹œ๊ฐ„๋ณต์žก๋„๊ฐ€ O(N)์ด๋‹ค.
๋ฐฐ์—ด๋ณด๋‹ค ๋งŽ์€ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

 

์ถœ์ฒ˜: https://yoongrammer.tistory.com/71

 

 

 

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
'Engineering/Algorithm' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
  • [์•Œ๊ณ ๋ฆฌ์ฆ˜] ๋‹ค์ด๋‚˜๋ฏน ํ”„๋กœ๊ทธ๋ž˜๋ฐ (feat. Leetcode)
  • [์ž๋ฃŒ๊ตฌ์กฐ] ํž™ (Heaps)
  • [Leetcode/Python] 5. Longest Palindromic Substring
  • [Leetcode/Python] 48. Rotate Image
AI๊ฑด์ถ•๊ฐ€
AI๊ฑด์ถ•๊ฐ€
LLMOps Engineer๋กœ ์ปค๋ฆฌ์–ด๋ฅผ ์Œ“๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ €๋งŒ์˜ ์‹œ์ ์œผ๋กœ AI๋ฅผ ํ•ด์„ํ•˜๊ณ ์ž ๋…ธ๋ ฅํ•ฉ๋‹ˆ๋‹ค. ํ•จ๊ป˜ ๋ฐฐ์šฐ๊ณ  ์„ฑ์žฅํ•˜๋Š” ๊ณต๊ฐ„์ด ๋˜์—ˆ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜Š๐Ÿš€
  • AI๊ฑด์ถ•๊ฐ€
    DeepFlame AI
    AI๊ฑด์ถ•๊ฐ€
  • ์ „์ฒด
    ์˜ค๋Š˜
    ์–ด์ œ
    • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ N
      • AI
      • Ops
      • Engineering
        • Algorithm
        • CS
        • BigData
        • Tools
      • Personal N
        • Toy Project
  • ๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

    • ํ™ˆ
    • ํƒœ๊ทธ
    • ๋ฐฉ๋ช…๋ก
  • ๋งํฌ

  • ๊ณต์ง€์‚ฌํ•ญ

  • ์ธ๊ธฐ ๊ธ€

  • ํƒœ๊ทธ

    mlops
    db
    LeetCode
    scala
    PostgreSQL
    DP
    ์„ธ๋ฏธ๋‚˜
    AWS
    Bio
    MSA
    kubernetes
    Cloud
    Python
    hadoop
    deepseek
    Hive
    airflow
    ec2
    mongoDB
    Ai
    algorithm
  • ์ตœ๊ทผ ๋Œ“๊ธ€

  • ์ตœ๊ทผ ๊ธ€

  • hELLOยท Designed By์ •์ƒ์šฐ.v4.10.6
AI๊ฑด์ถ•๊ฐ€
[์ž๋ฃŒ๊ตฌ์กฐ] Binary Search Tree
์ƒ๋‹จ์œผ๋กœ

ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”