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

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

by 조지 하이네만, 윤대석
May 2022
Beginner to intermediate
296 pages
5h 54m
Korean
Hanbit Media, Inc.
Content preview from 똑똑한 코드 작성을 위한 실전 알고리즘
184
똑똑한 코드 작성을 위한 실전 알고리즘
6.1
시작하기
연결 리스트와 배열은 정보를 선형 배치해 저장한다. 이 장에서는 컴퓨터 과학 분야에서 중요
한 개념인 재귀 자료구조의
이진 트리
binary
tree
를 소개한다.
5
장에서는 ‘자신을 호출하는 함수’라
재귀
의 개념을 학습했다. 이번 장에서는 이진 트리가 재귀 자료구조라는 것을 배운다. 즉,
이진 트리는 다른 이진 트리 구조를 참조한다는 의미다. 재귀 자료구조의 개념을 소개하기에
앞서 이미 학습한 연결 리스트 자료구조를 다시 한번 살펴보자.
연결 리스트는 각 노드에 하위 리스트의 첫 번째 노드를 참조하는
next
를 가지므로 재귀 자료
구조의 예가 된다. 연결 리스트는 값이
N
개인 컬렉션의 동적인 증가 및 축소를 지원해 고정 길
이 배열을 개선한다. [코드
6
-
1
]에서
sum
_
list
()
재귀 함수는 연결 리스트 내 값들의 총합을
반환한다. 이 구현을 전통적인 순회 방식과 비교해서 보자.
코드
6-1
연결 리스트 내 값들의 총합을 구하는 재귀 및 순회 함수
class Node:
def __init__(self, val, rest=None):
self.value = val
self.next = rest
def sum_iterative(n):
total = 0
while n:
total += n.value ...
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