I have a code to add a node...what would be a code to remove it if i provide the coeff
public void addNode(int coeff, int power)
{
if (head == null) // start the list
{
head = new Node(coeff, power, null);
degree = power;
}
else
{
Node n = head;
Node last = null;
while (n != null)
{
if (power > n.power) // insert in list
{
if (last == null)
head = new Node(coeff, power, n);
else
last.next = new Node(coeff, power, n);
degree = power;
break;
}
last = n;
n = n.next;
}
if (n == null) // append to list
{
last.next = new Node(coeff, power, null);
}
}
}