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

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

by 조지 하이네만, 윤대석
May 2022
Beginner to intermediate
296 pages
5h 54m
Korean
Hanbit Media, Inc.
Content preview from 똑똑한 코드 작성을 위한 실전 알고리즘
26
똑똑한 코드 작성을 위한 실전 알고리즘
1.4
모델로 알고리즘 성능 예측하기
누군가가 같은 문제에 대해 다른 알고리즘을 제시한다면? 어느 것을 사용할지 어떻게 결정할
까? [코드
1
-
3
]의
alternate
()
알고리즘을 보자.
A
에 있는 각 값을 반복적으로 확인해 리스
트 내 다른 값들보다 크거나 같은지 비교한다. 이 알고리즘이 옳은 결과를 반환할지, 크기가
N
인 문제에서 미만 연산을 몇 번 수행할지 확인해보자.
코드
1-3
A
에서 가장 큰 값의 위치를 찾는 다른 접근법
def alternate(A):
for v in A:
v_is_largest = True
for x in A:
if v < x:
v_is_largest = False
break
if v_is_largest:
return v
return None
A
를 순회할 때, 각 값
v
는 가장 큰 값이 될 수 있다.
v
가 다른 값 (
x
)보다 작으면 순회를 멈추고
v
는 가장 큰 값이 아닌 것으로 기록한다.
v_is_largest
True
이면
v
A
에서 최댓값이므로
v
를 반환한다.
A
가 빈 리스트이면
None
을 반환한다.
alternate
()
A
에서 모든
x
값보다 작지 않은
v
값을 찾는다. 구현에 중첩
for
루프를 사용
한다. 이번에는
x
에 대한 내부
for
루프가 ...
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