Exemplo n.º 1
0
        public DoublyLinkedListNode InsertIntoSortedList(DoublyLinkedListNode head, int data)
        {
            var nodeValues = new List <int>();

            nodeValues.Add(head.data);
            while (head.next != null)
            {
                nodeValues.Add(head.next.data);
                head = head.next;
            }
            nodeValues.Add(data);
            nodeValues.Sort();
            var newList = new DoublyLinkedList();

            foreach (var nodeValue in nodeValues)
            {
                newList.InsertNode(nodeValue);
            }
            return(newList.head);
        }
Exemplo n.º 2
0
 public DoublyLinkedList()
 {
     this.head = null;
     this.tail = null;
 }
 public DoublyLinkedListNode(int nodeData)
 {
     this.data     = nodeData;
     this.next     = null;
     this.previous = null;
 }