static void Main() { Linkedlist l1 = new Linkedlist(); l1.addLastWithTail(1); l1.addLastWithTail(5); l1.addLastWithTail(7); l1.addLastWithTail(9); l1.changenext(ref l1.head); l1.printList(); }
static void Main() { Linkedlist l1 = new Linkedlist(); l1.addLastWithTail(1); l1.addLastWithTail(9); l1.addLastWithTail(4); l1.addLastWithTail(2); //l1.addLastWithTail(3); //l1.addLastWithTail(5); l1.mergesort(ref l1.head); l1.printwithnode(l1.head); }
static void Main() { Linkedlist l1 = new Linkedlist(); l1.addLastWithTail(1); l1.addLastWithTail(5); l1.addLastWithTail(7); l1.addLastWithTail(9); Linkedlist l2 = new Linkedlist(); l2.addLastWithTail(1); l2.addLastWithTail(5); l2.addLastWithTail(7); l2.addLastWithTail(11); if (l1.recursiveAreIdentical(l1.head, l2.head)) { Console.WriteLine("Identical"); } else { Console.WriteLine("not"); } //Linkedlist l3=new Linkedlist(); //l3.sortedMerge(l1.head,l2.head); //l3.head= l3.recursiveSortedMerge(l1.head,l2.head); //Linkedlist l3=new Linkedlist(); //l1.alternateSplit(l1.head,l2,l3); //l3.printList(); //Console.WriteLine("next"); //l3.printList(); //l1.AddLast(1); //l1.AddLast(2); //l1.AddLast(3); //l1.AddLast(4); //l1.insertAfter(l1.head.next.next,8); //l1.insertBefore(l1.head.next,9); //l1.printList(); //Console.WriteLine("Number of elements are {0}",l1.getIterativeCount()); //Console.WriteLine("Number of elements are {0}",l1.getRecursiveCount(l1.head)); //l1.deleteLinkedList(); //Console.WriteLine("Number of elements are {0}",l1.getIterativeCount()); //if(l1.isPalindromeMain(l1.head)) //{ //Console.WriteLine("LL is palindrome"); //} //else //{ // Console.WriteLine("Not"); //} //l1.printList(); }
public void sortedMerge(Node a, Node b) { Node current1 = a; Node current2 = b; Linkedlist l3 = new Linkedlist(); if (a == null) { l3.head = b; return; } if (b == null) { l3.head = a; return; } while (current1 != null && current2 != null) { if (current1.data <= current2.data) { l3.addLastWithTail(current1.data); current1 = current1.next; } else { l3.addLastWithTail(current2.data); current2 = current2.next; } } if (current1 == null) { l3.tail.next = current2; } if (current2 == null) { l3.tail.next = current1; } l3.printList(); }
static void Main() { Linkedlist l1=new Linkedlist(); l1.addLastWithTail(1); l1.addLastWithTail(5); l1.addLastWithTail(7); l1.addLastWithTail(9); Linkedlist l2=new Linkedlist(); l2.addLastWithTail(1); l2.addLastWithTail(5); l2.addLastWithTail(7); l2.addLastWithTail(11); if(l1.recursiveAreIdentical(l1.head,l2.head)) { Console.WriteLine("Identical"); } else { Console.WriteLine("not"); } //Linkedlist l3=new Linkedlist(); //l3.sortedMerge(l1.head,l2.head); //l3.head= l3.recursiveSortedMerge(l1.head,l2.head); //Linkedlist l3=new Linkedlist(); //l1.alternateSplit(l1.head,l2,l3); //l3.printList(); //Console.WriteLine("next"); //l3.printList(); //l1.AddLast(1); //l1.AddLast(2); //l1.AddLast(3); //l1.AddLast(4); //l1.insertAfter(l1.head.next.next,8); //l1.insertBefore(l1.head.next,9); //l1.printList(); //Console.WriteLine("Number of elements are {0}",l1.getIterativeCount()); //Console.WriteLine("Number of elements are {0}",l1.getRecursiveCount(l1.head)); //l1.deleteLinkedList(); //Console.WriteLine("Number of elements are {0}",l1.getIterativeCount()); //if(l1.isPalindromeMain(l1.head)) //{ //Console.WriteLine("LL is palindrome"); //} //else //{ // Console.WriteLine("Not"); //} //l1.printList(); }
public void sortedMerge(Node a,Node b) { Node current1=a; Node current2=b; Linkedlist l3=new Linkedlist(); if(a==null) { l3.head=b; return; } if(b==null) { l3.head=a; return; } while(current1!=null &¤t2!=null) { if(current1.data<=current2.data) { l3.addLastWithTail(current1.data); current1=current1.next; } else { l3.addLastWithTail(current2.data); current2=current2.next; } } if(current1==null) { l3.tail.next=current2; } if(current2==null) { l3.tail.next=current1; } l3.printList(); }
static void Main() { Linkedlist l1=new Linkedlist(); l1.addLastWithTail(1); l1.addLastWithTail(9); l1.addLastWithTail(4); l1.addLastWithTail(2); //l1.addLastWithTail(3); //l1.addLastWithTail(5); l1.mergesort(ref l1.head); l1.printwithnode(l1.head); }