# Hide and Seek4 2회차

역으로 출력해야할 때 재귀함수 구현 방법

일단 뼈대부터 생각을 해보면\
print(int x) {\
&#x20; if(x==n) {x출력}\
&#x20; else{ print(from\[x]);}\
}

이렇게 1차로 생각했다. 그런데 매개변수 x가 n과 같을 때만 x가 출력되기 때문에, 재귀함수가 호출,실행된후 리턴되고 난 다음을 생각하지 못했다!\
from\[x]==n을 먼저 출력하고 나면 리턴되고 나서 현재의 함수에서 매개변수 x를 출력하고, 그 다음 재귀함수에서 x를 출력하는 방법으로 구현해준다!

![재귀함수 호출 구체화 및 도식화](/files/-McEUWJPp1mhZkaemPuL)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/algorithms-problem-solving-skills/graph/hide-and-seek4-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
