Esempio n. 1
0
    static void Main()
    {
        Linkedlist l1 = new Linkedlist();

        l1.AddFirst(3);
        l1.AddFirst(2);
        l1.AddFirst(6);
        l1.AddFirst(5);
        l1.AddFirst(11);
        l1.AddFirst(10);
        l1.AddFirst(15);
        l1.AddFirst(12);
        //l1.head= l1.reverseAlternateBySize(l1.head,3,true);
        //l1.deleteNodesWithLessValue(l1.head);
        l1.segregateEvenAndOdd(ref l1.head);
        l1.printwithnode(l1.head);
        //l1.printList();
        //l1.printList();
        // int size=l1.getIterativeCount();
        // Linkedlist l2= new Linkedlist();
        // l2.head=l1.IterativeReverse();
        // for(int i=0;i<size;i++)
        // {
        //  Node head1=l1.head,head2=l2.head;
        //  if(head1.data!=head2.data)
        //  {
        //      Console.WriteLine("Not Palindrome");
        //      break;
        //  }
        //  head1=head1.next;
        //  head2=head2.next;
        // }
        // l1.printList();
    }
 public void alternateSplit(Node head,Linkedlist a,Linkedlist b)
 {
     Node current=head;
     while(current !=null)
     {
         a.AddFirst(current.data);
         current=current.next;
         if(current!=null)
         {
             b.AddFirst(current.data);
             current=current.next;
         }
     }
 }
    public void alternateSplit(Node head, Linkedlist a, Linkedlist b)
    {
        Node current = head;

        while (current != null)
        {
            a.AddFirst(current.data);
            current = current.next;
            if (current != null)
            {
                b.AddFirst(current.data);
                current = current.next;
            }
        }
    }
    static void Main()
    {
        Linkedlist l1 = new Linkedlist();

        l1.AddFirst(5);
        l1.addNodeDown(l1.head, 7);
        l1.addNodeDown(l1.head.down, 8);
        l1.addNodeDown(l1.head.down.down, 30);
        l1.addNodeRight(l1.head, 10);
        l1.addNodeRight(l1.head.right, 19);
        l1.addNodeDown(l1.head.right.right, 22);
        l1.addNodeDown(l1.head.right.right.down, 50);
        l1.addNodeDown(l1.head.right, 20);
        l1.head = l1.flattenFunction(l1.head);
        l1.print();
        //l1.printlist();
    }
 static void Main()
 {
     Linkedlist l1=new Linkedlist();
     l1.AddFirst(5);
     l1.addNodeDown(l1.head,7);
     l1.addNodeDown(l1.head.down,8);
     l1.addNodeDown(l1.head.down.down,30);
     l1.addNodeRight(l1.head,10);
     l1.addNodeRight(l1.head.right,19);
     l1.addNodeDown(l1.head.right.right,22);
     l1.addNodeDown(l1.head.right.right.down,50);
     l1.addNodeDown(l1.head.right,20);
     l1.head= l1.flattenFunction(l1.head);
     l1.print();
     //l1.printlist();
 }
 static void Main()
 {
     Linkedlist l1=new Linkedlist();
     l1.AddFirst(3);
     l1.AddFirst(2);
     l1.AddFirst(6);
     l1.AddFirst(5);
     l1.AddFirst(11);
     l1.AddFirst(10);
     l1.AddFirst(15);
     l1.AddFirst(12);
     //l1.head= l1.reverseAlternateBySize(l1.head,3,true);
     //l1.deleteNodesWithLessValue(l1.head);
     l1.segregateEvenAndOdd(ref l1.head);
     l1.printwithnode(l1.head);
     //l1.printList();
     //l1.printList();
     // int size=l1.getIterativeCount();
     // Linkedlist l2= new Linkedlist();
     // l2.head=l1.IterativeReverse();
     // for(int i=0;i<size;i++)
     // {
     // 	Node head1=l1.head,head2=l2.head;
     // 	if(head1.data!=head2.data)
     // 	{
     // 		Console.WriteLine("Not Palindrome");
     // 		break;
     // 	}
     // 	head1=head1.next;
     // 	head2=head2.next;
     // }
     // l1.printList();
 }