public void PrintValues() { SllNode runner = Head; while (runner != null) { Console.WriteLine(runner.Value); runner = runner.Next; } }
public void PrintNextValue() { SllNode runner = Head; while (runner.Next != null) { Console.WriteLine("Current Node: " + runner.Value + " .Next Value: " + runner.Next.Value); runner = runner.Next; } }
static void Main(string[] args) { SinglyLinkedList newList = new SinglyLinkedList(); newList.add(2).add(3).add(5).add(20); newList.printValues(); newList.printValues(); SllNode node = newList.find(5); Console.WriteLine(node.value); }
static void Main(string[] args) { SllNode one = new SllNode(1); SllNode two = new SllNode(2); SllNode three = new SllNode(3); SinglyLinkedList head = new SinglyLinkedList(); head.Head = one; one.Next = two; two.Next = three; Console.WriteLine(head.Find(3).Value); }
public void Remove() { if (Head != null) { SllNode runner = Head; while (runner.Next.Next != null) { runner = runner.Next; } runner.Next = null; } }
public int?Find(int value) { SllNode runner = Head; while (runner != null) { if (runner.Value == value) { return(runner.Value); } runner = runner.Next; } return(null); }
public void RemoveTail() { if (Head.Next == null) { Head = null; } else { SllNode runner = Head; while (runner.Next.Next != null) { runner = runner.Next; } runner.Next = null; } }
public void PrintValues() { SllNode current = Head; if (current == null) { Console.WriteLine("No nodes to print"); } else { while (current != null) { Console.WriteLine("Node: " + current.Value); current = current.Next; } } }
public void Add(int value) { SllNode newNode = new SllNode(value); if (Head == null) { Head = newNode; } else { SllNode runner = Head; while (runner.Next != null) { runner = runner.Next; } runner.Next = newNode; } }
public void printValues() { if (head == null) { Console.WriteLine("No values"); } else { List <int> nodeValues = new List <int>(); SllNode runner = head; while (runner != null) { nodeValues.Add(runner.value); runner = runner.next; } Console.WriteLine(string.Join(", ", nodeValues)); } }
public SllNode Find(int value) { SllNode runner = Head; while (runner != null) { if (runner.Value != value) { runner = runner.Next; } else { return(runner); } } Console.WriteLine("Not Found"); return(null); }
public SllNode find(int Ivalue) { if (head != null) { SllNode runner = head; while (runner != null) { if (runner.value == Ivalue) { return(runner); } else { runner = runner.next; } } } return(null); }
public SinglyLinkedList remove() { if (head.next == null) { head = null; return(this); } if (head != null) { SllNode runner = head; while (runner.next.next != null) { runner = runner.next; } runner.next = null; return(this); } return(null); }
public void Remove() { if (Head.Next == null) { Head = null; } else { SllNode runner = Head; SllNode runnerTwo = Head.Next; while (runnerTwo.Next != null) { runner = runnerTwo; runnerTwo = runnerTwo.Next; } runner.Next = null; } }
public void removeAt(int nthNode) { if (head != null) { int count = 0; SllNode runner = head; while (runner != null) { if (count == nthNode - 1) { runner.next = runner.next.next; } else { runner = runner.next; count++; } } } }
// SLL methods go here. As a starter, we will show you how to add a node to the list. public SinglyLinkedList add(int value) { SllNode newNode = new SllNode(value); if (head == null) { head = newNode; return(this); } else { SllNode runner = head; while (runner.next != null) { runner = runner.next; } runner.next = newNode; return(this); } }
public SinglyLinkedList() { head = null; }
public SinglyLinkedList() { // your code here Head = null; }
public SllNode(int value) { Value = value; Next = null; }