Example #1
0
        private Node016 Merge(Node016 head1, Node016 head2)
        {
            if (head1 == null)
            {
                return(head2);
            }
            else if (head2 == null)
            {
                return(head1);
            }

            Node016 newNode = null;

            if (head1.Data >= head2.Data)
            {
                newNode      = head2;
                newNode.Next = Merge(head1, head2.Next);
            }
            else
            {
                newNode      = head1;
                newNode.Next = Merge(head1.Next, head2);
            }
            return(newNode);
        }
Example #2
0
        internal void Add(Int32 data)
        {
            var newNode = new Node016
            {
                Data = data
            };

            if (_head == null)
            {
                _head = newNode;
                return;
            }

            var innerHead = _head;

            while (innerHead.Next != null)
            {
                innerHead = innerHead.Next;
            }

            innerHead.Next = newNode;
        }