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

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

by 조지 하이네만, 윤대석
May 2022
Beginner to intermediate
296 pages
5h 54m
Korean
Hanbit Media, Inc.
Content preview from 똑똑한 코드 작성을 위한 실전 알고리즘
279
7
장
그래프
7.10
연습 문제
1.
깊이 우선 탐색은 재귀적으로 코딩할 수 있지만 대형 그래프를 탐색할 때는 약점이 있다
(파이썬은 재귀가 약
1
,
000
회로 제한되기 때문이다 ). 작은 미로에 대해서는
search
를 수
정해 재귀적 탐색을 사용할 수 있다. 재귀적으로 깊이 우선 탐색을 수행하기 위한 [코드
7
-
19
]의 스켈레톤 코드
skeleton
code
를 수정하자. 스택을 사용해 제거하고 처리할 방문 노드
를 저장하는 대신, 방문 노드에
dfs
()
만을 수행하고 선택하지 않은 경로를 찾기 위해 재귀
풀기를 진행한다.
코드
7-19
깊이 우선 탐색에 대한 재귀적 구현을 완성하자
def dfs_search_recursive(G, src):
marked = {}
node_from = {}
def dfs(v):
"""이 재귀 함수를 채우자."""
dfs(src)
return node_from
2.
너비 우선 탐색과 깊이 우선 탐색에 대한 경로를 계산하는
path
_
to
()
함수는 재귀적으
로 구현될 수 있다.
src
에서
target
까지 순서대로 노드를 생성하는 파이썬 제너레이터인
path
_
to
_
recusive
(
node
_
from
,
src
,
target
)
을 구현하자.
3.
순환이 존재하면 이를 검출하고 반환하는
recover
_
cycle
(
G
)
함수를 설계하자.
4. ...
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

AI를 위한 필수 수학

AI를 위한 필수 수학

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

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

루크 아버클, 칼리드 엘 에맘

Publisher Resources

ISBN: 9791162245644