본문 바로가기

recursion

알고리즘 코딩기법 - 3. 재귀호출 안녕하세요.. 저번 포스팅에서 예고해드린데로 이번에는 재귀호출에 대해서 다뤄볼까합니다. 물론 멤버십에 계신분들중에 재귀호출을 어려워 하실 분들은 없으리라 생각하는데요, 학교에서 주위를 살펴보면 재귀호출을 잘 못하는 친구나, 후배나, 등등 많은 것 같습니다. 그 만큼 재귀호출이 직관적으로 이해가 잘 안되는 부분인가 봅니다. C++과 싸우다 보면 포인터에서 한 번 좌절을 하게 되고 포인터를 넘고나면 재귀호출이 또다시 태클을 건다는.. 뭐 그런 전설이 내려오는데요.. 저도 지금 재귀호출을 어떻게 다뤄야할지 막막합니다 ㅠㅠ 뭐.. 어쨌든..... 각설하고 시작하겠습니다. 재귀(Recursion) 주어진 문제를 재귀적으로 푼다는 말은 문제의 답이 그 문제와 동일한 형태의 더 작은 부분문제(sub problem)의.. 더보기
Party at Hali-Bula http://acm.pku.edu.cn/JudgeOnline/problem?id=3342 Description Dear Contestant, I'm going to have a party at my villa at Hali-Bula to celebrate my retirement from BCM. I wish I could invite all my co-workers, but imagine how an employee can enjoy a party when he finds his boss among the guests! So, I decide not to invite both an employee and his/her boss. The organizational hierarchy at BCM is su.. 더보기
Barbara Bennett's Wild Numbers http://acm.pku.edu.cn/JudgeOnline/problem?id=3340 Description A wild number is a string containing digits and question marks (like 36?1?8). A number X matches a wild number W if they have the same length, and every non-question mark character in X is equal to the character in the same position in W (it means that you can replace a question mark with any digit). For example, 365198 matches the wi.. 더보기