private SLNode Add(SLNode node, int data) { if (node == null) { return(new SLNode(data)); } node.Next = Add(node.Next, data); return(node); }
static bool RemoveNode(SLNode node) { if (node == null || node.Next == null) { return(false); } SLNode next = node.Next; node.Data = next.Data; node.Next = next.Next; return(true); }
static public int[] ToArray(SLNode node) { SLNode curr = node; List <int> l = new List <int>(); while (curr != null) { l.Add(curr.Data); curr = curr.Next; } return(l.ToArray()); }
private SLNode FindNode(SLNode node, int data) { if (node == null) { return(null); } if (node.Data == data) { return(node); } else { return(FindNode(node.Next, data)); } }
public void Add(int data) { root = Add(root, data); }