본문 바로가기

자료구조

재귀적으로 스택의 모든 데이터를 출력

더보기
4차
더보기
https://diymaker.tistory.com/118?category=729231

https://diymaker.tistory.com/118?category=729231

 

어..? 재귀함수란게 순서도로 그리려면.. 생략하는방법이없다면.. 무한히 그려야 되는거 아닐까..?

public void Print()
{
    if (this.top == null)
    {
   	 Console.WriteLine("스택이 비어있습니다.");
    }
    else
    {
   	 PrintRecursive(this.top);
    }
}

void PrintRecursive(Node node)
{
   	 Console.WriteLine("data: {0}", node.Data);
    if (node.Next != null)
    {
  	 PrintRecursive(node.Next);
    }
}

2차 3차 사실 맞게 그린듯