Q:
Write functions Insert and Remove which add and remove nodes from ordered single linked list based on the Node value
A:
public Node Insert(Node head, int value)
  {
        if (head == null || value < head.value)
            return new Node(value, head);
        else
        {
            head.next = Insert(head.next, value);
            return head;
        }
    }
Subscribe to:
Post Comments (Atom)
 
 

No comments:
Post a Comment