Ejemplo n.º 1
0
 public void Unique(Node node)
 {
     while(node.Next != null)
     {
         Node rabbit = node.Next;
         while (rabbit.Next != null)
         {
             if (rabbit.Value == rabbit.Next.Value)
                 rabbit.Next = rabbit.Next.Next;
             else
             {
                 rabbit = rabbit.Next;
             }
         }
         node = node.Next;
     }
 }
Ejemplo n.º 2
0
        public bool IsCircular(Node start)
        {
            Node slow = start;
            Node fast = start.Next;

            while(fast != null)
            {
                //Is Circular
                if (slow == fast)
                    return true;
                //Def not circular
                else if (fast.Next == null)
                    return false;

                slow = slow.Next;
                fast = fast.Next.Next;
            }

            return false;
        }
Ejemplo n.º 3
0
 public LinkedList(Node node)
 {
     Head = node;
     Tail = node;
 }
Ejemplo n.º 4
0
 void Add(Node node)
 {
     if (Tail != null)
         Tail.Next = node;
 }
Ejemplo n.º 5
0
 public Node(Node next, object value)
 {
     Next = next;
     Value = value;
 }