public void AddFirst(int data) { LinkedListNode current = new LinkedListNode(); current.setData(data); current.setNext(head); head = current; }
/// <summary> /// /// </summary> /// <param name="data"></param> public void AddLast(int data) { if (head == null) { head = new LinkedListNode(); head.setData(data); head.setNext(null); } LinkedListNode toAdd = new LinkedListNode(); toAdd = head; while (toAdd.getNext() != null) { toAdd = toAdd.getNext(); } toAdd.setData(data); }
/// <summary> /// /// </summary> /// <param name="args"></param> public static void Main(string[] args) { Console.WriteLine("Hello World!"); LinkedListNode node1 = new LinkedListNode(); LinkedListNode node2 = new LinkedListNode(); LinkedListNode node3 = new LinkedListNode(); node1.setData(20); node1.setNext(node2); node2.setData(10); node2.setNext(node3); node3.setData(10); node3.setNext(null); CenterLinkedList center = new CenterLinkedList(); LinkedListNode n = center.FindCenter(node1); Console.WriteLine("Center of the list is-: {0}", n.getData()); DeleteItemFromLinkedList d = new DeleteItemFromLinkedList(); LinkedListNode node = d.DeleteNode(node1, 10); }