public void PrintLinkedListInReverse(ImmutableListNode head) { if (head == null) { return; } PrintLinkedListInReverse(head.GetNext()); head.PrintValue(); }
public void PrintLinkedListInReverse(ImmutableListNode head) { Stack <ImmutableListNode> st = new Stack <ImmutableListNode>(); while (head.GetNext() != null) { st.Push(head); head = head.GetNext(); } st.Push(head); while (st.Count() != 0) { st.Pop().PrintValue(); } }
public ImmutableListNode(IList <int> list, int value, ImmutableListNode next) : base(value) { this.list = list; this.next = next; }