다음 하노이 탑 문제를 해결하는 파이썬(Python) 코드의 시간 복잡도는? (단, n은 원판의 개수이고 first, second, third는 기둥 번호이다)
def hanoiT(n, first, second, third):
if n == 1:
print("원판1 : %s 에서 %s"%(first, third))
else:
hanoiT(n - 1, first, third, second)
print("원판%d : %s 에서 %s"%(n, first, third))
hanoiT(n - 1, second, first, third)- ①
- ②
- ③
- ④
선지를 골라 바로 채점해 보세요.
정답 ③
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)