示例#1
0
        public void AddFirst(int data)
        {
            LinkedListNode current = new LinkedListNode();

            current.setData(data);
            current.setNext(head);
            head = current;
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <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);
        }