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

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

by 유동환, 앨런 B. 다우니
June 2018
Beginner to intermediate
184 pages
3h 30m
Korean
Hanbit Media, Inc.
Content preview from 자바로 배우는 핵심 자료구조와 알고리즘: 기술 면접에 필요한 실용주의 자료구조와 알고리즘
123
12
TreeMap 클래스
}
}
각 노드는 키-값 쌍을 포함하며, 두 자식 노드인
left
right
변수를 참조합니다. 자식 노드
는 둘 중 하나 또는 둘 다
null
이 될 수 있습니다.
Map
인터페이스의 일부 메서드는
size
clear
처럼 구현하기 쉽습니다
(파일명:
MyTreeMap.
java
)
.
public int size
()
{
return size
;
}
public void clear
()
{
size
=
0
;
root
=
null
;
}
size
메서드는 확실히 상수 시간입니다.
clear
메서드는 상수 시간으로 보지만, 고려해야 할 점이 있습니다.
root
변수가
null
이 되면
가비지 컬렉터는 트리에 있는 노드 객체의 수거를 요청하며, 이는 선형 시간이 걸립니다. 가비
지 컬렉터가 수행하는 작업 시간을 세야 할까요? 필자는 그렇다고 생각합니다.
다음 절에서는
get
put
메서드와 같이 가장 중요한 몇 개 메서드를 채우겠습니다.
12.4
TreeMap
구현하기
이 책의 코드 저장소에는 다음과 같은 소스 파일이 있습니다.
MyTreeMap
.
java
앞 절의 코드와 빠진 메서드의 개요가 담겨 있습니다.
MyTreeMapTest
.
java
MyTreeMap
클래스의 유닛 테스트 파일입니다.
124
자바로 배우는 핵심 자료구조와 알고리즘 ...
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