public void AddNodeAtFirstToLinkedList(int num) { var newNode = new LinkedNode() { data = num, next = null }; var node = head; newNode.next = head.next; head.next = newNode; }
public void AddNodeAtLastToLinkedList(int num) { var newNode = new LinkedNode() { data = num, next = null }; var node = head; while (node.next != null) { node = node.next; } node.next = newNode; }
public void AddNodeAfterKthNode(int num, int k) { var newNode = new LinkedNode() { data = num, next = null }; var node = head.next; while (node.next != null) { if (node.data.Equals(k)) { break; } } newNode.next = node.next; node.next = newNode; }
public LinkedList() { head = new LinkedNode(); current = head; }