public string Display(Node_LinkedList head) { string result = String.Empty; Node_LinkedList start = head; StringBuilder sb = new StringBuilder(); while (start != null) { sb.AppendFormat("{0} ", start.Data); start = start.Next; } result = sb.ToString(); return(result); }
protected string PrintLinkedList(Node_LinkedList head) { string result; StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} ", head.Data); while (head.Next != null) { head = head.Next; sb.AppendFormat("{0} ", head.Data); } result = sb.ToString(); return(result); }
public Node_LinkedList RemoveDuplicateNodes(Node_LinkedList head) { var current = head; int nodeData = current.Data; while (current.Next != null) { if (nodeData == current.Next.Data) { var duplicate = current.Next; current.Next = duplicate.Next; duplicate = null; } else { current = current.Next; nodeData = current.Data; } } return(head); }
public Node_LinkedList Insert(Node_LinkedList head, int data) { Node_LinkedList nextNode = new Node_LinkedList(data); //Complete this method if (head != null) { Node_LinkedList tail = head; while (tail.Next != null) { tail = tail.Next; } tail.Next = nextNode; } else { head = nextNode; } return(head); }