Ejemplo n.º 1
0
            public void MargeSortedList(MargeNode first, MargeNode second)
            {
                int x = Convert.ToInt32(first.Next.Data.ToString());
                int y = Convert.ToInt32(second.Data.ToString());

                if (x > y)
                {
                    MargeNode temp = first;
                    first  = second;
                    second = first;
                }
                head = first;
                while ((first.Next != null) && (second != null))
                {
                    if (x < y)
                    {
                        first = first.Next;
                    }
                    else
                    {
                        MargeNode next = first.Next;
                        MargeNode temp = second.Next;
                        first.Next  = second;
                        second.Next = next;
                        first       = first.Next;
                        second      = temp;
                    }
                }
                if (first.Next == null)
                {
                    first.Next = second;
                }
            }
Ejemplo n.º 2
0
            public void Print()
            {
                MargeNode current = head;

                while (current != null)
                {
                    Console.Write(" {0} ", current.Data);
                    current = current.Next;
                }
                Console.Write("\n");
            }
Ejemplo n.º 3
0
 public void addToTheLast(MargeNode value)
 {
     if (head == null)
     {
         head    = value;
         current = head;
     }
     else
     {
         current.Next = value;
         current      = current.Next;
     }
 }