public void AddToSorted(int data) { if (headNode == null) { headNode = new Node(data); } else if (data < headNode.data) { AddToBeginning(data); } else { headNode.AddToSorted(data); } }
public void AddToSorted(int data) { if (next == null) { next = new Node(data); } else if (data < next.data) { Node temp = new Node(data); temp.next = this.next; this.next = temp; } else { next.AddToSorted(data); } }