Notice
Recent Posts
Recent Comments
Link
목록삽입 (1)
헬창 개발자
AVL 트리 구현 : 파이썬
설계도 오른쪽 회전의 알고리즘 루트 노드 n에서 불균형이 발견된다면, n.left를 x로 선언하고 n.left를 x.right로 만들어줘 연결을 끊는다. x.right에 n을 연결해줘 서브트리로 갱신한다. 왼쪽 회전은 방향만 바꿔주면 된다. 코드 class Node: def __init__(self, key, height, left=None, right=None): self.key = key self.height = height self.left = left self.right = right class AVL: def __init__(self): self.root = None def height(self, n): if n == None: return 0 return n.height def put(self..
자료구조
2021. 9. 7. 14:50