• 카테고리

    질문 & 답변
  • 세부 분야

    취업 · 이직

  • 해결 여부

    미해결

스택의 재귀에 대해서 선장님께서 말씀하신 부분 디버깅 한 내용 공유드립니다~!

21.01.27 13:47 작성 조회수 149

0

* 스택 재귀
* 재귀를 생각할때는 작은 단위로 생각하라
*
* 1 2 3
*
* solution2 - 1 2 3
*
* solution2 - 1 2 - pop(3)
* solution2 - 1 - pop(2)
* solution2 - - pop(1)
*
* *************solution2 - - pop(1)*************
* insertAtBottom - null , 1
* 1 push
*
* 현재 스택 [1]
**************solution2 - - pop(1)*************
*
**************solution2 - 1 - pop(2)*************
* insertAtBottom - [1] , 2
* pop 1
* insertAtBottom - null , 2
* push 2
* push 1
*
* 현재 스택 [1 2]
*
**************solution2 - 1 2 - pop(3)*************
* insertAtBottom [1 2] , 3
* pop 1
* insertAtBottom [2] , 3
* pop 2
* insertAtBottom null , 3
* push 3
* push 2
* push 1
*
* 현재 스택 [1 2 3]
**************solution2 - 1 2 - pop(3)*************

답변 1

답변을 작성해보세요.

1

오.. 감사합니다.