Skip to Content
똑똑한 코드 작성을 위한 실전 알고리즘
book

똑똑한 코드 작성을 위한 실전 알고리즘

by 조지 하이네만, 윤대석
May 2022
Beginner to intermediate
296 pages
5h 54m
Korean
Hanbit Media, Inc.
Content preview from 똑똑한 코드 작성을 위한 실전 알고리즘
197
6
이진 트리
6.4
이진 탐색 트리에서 값 제거하기
연결 리스트에서 값을 제거하는 작업은
3
장에서 학습했듯 비교적 직관적인 반면, 이진 탐색 트
리에서 값을 제거하는 작업은 좀 더 까다롭다. 만약 루트 노드에 포함된 값을 제거한다면, ‘함
께 붙어 있던’ 고아가 된 왼쪽과 오른쪽 하위 트리는 어떻게 해야 할까? 또한 매번 작동하는 일
관되게 노력이 최소한으로 필요한 전략이 있어야 한다. 이진 탐색 트리의 루트 노드에 포함된
값을 제거하는 직관적인 해결책을 찾아보자. [그림
6
-
6
]은 값이
19
인 루트 노드를 제거한 후
에 가능한 이진 탐색 트리 두 가지를 보여준다.
그림
6-6
[그
6
-
4
]에서
19
를 제거한 후에 가능한 이진 탐색 트리 두 가지
두 옵션 모두 이진 탐색 트리를 유지한다. 각 왼쪽 하위 트리의 값은 여전히 루트 값보다 작거
나 같고, 각 오른쪽 하위 트리의 값은 여전히 루트 값보다 크거나 같다. 두 옵션 모두 이진 탐색
트리를 유지하기 위한 동작을 최소화하려고 노력한다.
옵션 #
1
: 왼쪽 하위 트리에서 최댓값을 찾아 제거해 루트 값으로 사용한다.
옵션 #
2
: 오른쪽 하위 트리에서 최솟값을 찾아 제거해 루트 값으로 사용한다.
두 옵션 모두 유효하며 필자는 두 번째를 선택한다. 새로운 루트 값
26
은 원래 오른쪽 하위 트
리에서 가장 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

데이터 익명화를 위한 파이프라인

데이터 익명화를 위한 파이프라인

루크 아버클, 칼리드 엘 에맘
개발 7년차, 매니저 1일차

개발 7년차, 매니저 1일차

권원상, 한민주, 카미유 푸르니에

Publisher Resources

ISBN: 9791162245644