트리 (Trees)

Henry Lee·2020년 12월 3일
0
post-thumbnail

1. 용어들
node, edge
root, leaf
parent, child

트리의
depth(height)

노드의

leveldegree
root = 0root = 1

2. 이진 트리 (Binary Trees)
모든 node가
자식이 없거나,
하나만 있거나,
둘 있거나..

일단 구현

class Node:
	def __init__(self, item):
          self.data = item
          self.left = None
          self.right = None
# edge로 left, right 초기화

class BinaryTree:
	def __init(self, root_node):
    		self.root = root_node

3. 이진 탐색 트리 (Binary Search Trees)
(정렬된) 배열을 이용한 이진 탐색과 상당히 유사.
삭제 연산(remove())의 구현이 까다로웠음.

더 공부할 것들

  • 삭제 연산
  • AVL trees
  • Red-black trees
profile
Today I Learned. AI Engineer.

0개의 댓글