Skip to Content
자바로 배우는 핵심 자료구조와 알고리즘: 기술 면접에 필요한 실용주의 자료구조와 알고리즘
book

자바로 배우는 핵심 자료구조와 알고리즘: 기술 면접에 필요한 실용주의 자료구조와 알고리즘

by 유동환, 앨런 B. 다우니
June 2018
Beginner to intermediate
184 pages
3h 30m
Korean
Hanbit Media, Inc.
Content preview from 자바로 배우는 핵심 자료구조와 알고리즘: 기술 면접에 필요한 실용주의 자료구조와 알고리즘
133
13
이진 탐색 트리
같은 내용을 재귀적으로 적용하면 왼쪽 하위와 오른쪽 하위 트리의 요소들이 순서대로 되어 있
음을 알 수 있습니다. 기저 사례 또한 충족합니다. 즉, 하위 트리가 비어 있으면 키는 추가되지
않습니다. 따라서 이 메서드는 올바른 순서로 모든 키를 추가하게 됩니다.
이 메서드는 트리에 있는 모든 노드를 방문하므로
containsValue
메서드와 마찬가지로 실행
시간은
n
에 비례합니다.
13.5
로그 시간 메서드
MyTreeMap
클래스에서
get
put
메서드는 실행시간이 트리의 높이인
h
에 비례합니다. 실습
10
에서 트리가 가득 차면, 즉 트리의 모든 수준이 노드를 최대로 포함하면 트리의 높이는
log
n
에 비례한다고 하였습니다.
또한
get
put
메서드도 로그 시간입니다. 즉, 실행시간이
log
n
에 비례합니다. 하지만 대부
분 응용 프로그램에서 트리가 가득 찬다고 보장할 수 없습니다. 일반적으로 트리의 모양은 키
와 키가 추가되는 순서에 따릅니다.
이것이 실제로 어떻게 동작하는지 알아보고자 두 개의 예제 데이터로 우리의 구현을 테스트해
보겠습니다. 두 예제 데이터는 무작위 문자열 리스트와 증가하는 타임스탬프 리스트입니다.
다음은 난수 문자열을 생성하는 코드입니다
(파일명:
MyTreeMapExample.java
)
.
Map ...
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

자바 마이크로서비스를 활용한 SRE : 기업에서 신뢰할 수 있는 마이크로서비스를 위한 패턴

자바 마이크로서비스를 활용한 SRE : 기업에서 신뢰할 수 있는 마이크로서비스를 위한 패턴

조너선 슈나이더

Publisher Resources

ISBN: 9791162240847