All pastes #904121 Raw Edit

hhh

public text v1 · immutable
·published 2008-02-14 19:00 UTC
rendered paste body
    public static Node<int> Eleven(Node<int> chain1, Node<int> chain2)
    {
        // A:
        Node<int> newChain = new Node<int>(chain1.GetInfo());
        Node<int> pos = newChain;
        while (chain1.GetNextNode() != null)
        {
            pos.SetNext(chain1.GetNextNode());
            chain1 = chain1.GetNextNode();
            pos = pos.GetNextNode();
        }
        while (chain2.GetNextNode() != null)
        {
            pos.SetNext(chain2);
            chain2 = chain2.GetNextNode();
            pos = pos.GetNextNode();
        }
        return newChain;
        // B:
        Node<int> pos = chain1;
        while (pos.GetNextNode() != null)
        {
            pos = pos.GetNextNode();
        }
        pos.SetNext(chain2);

        return chain1;
    }