The problem i got now is the following, and i'd REALLY be grateful if someone could assist me with this. Lets say i have 6 nodes and the long link is 3, then 1 points to 2 and 4, 2 points to 3 and 5, 3 points to 4 and 6 etc .....
When i delete node 1 and 2, then nodes 4 and 5 are longlinking back to 0 (for some reason). Can someone help me please? Code is here:
Code:
node *newnode = current;
node *temp = current;
node *start = current;
node *longlinker = current;
int number = 0;
for (int i = 1; i < length; i++)
{
temp = temp -> shortlink;
}
if (newnode -> num == x)
{
start = start -> shortlink;
number = current -> longlink -> num;
current = current -> shortlink;
temp -> shortlink = start;
delete newnode;
length--;
cout << "longlink for 1 is" << number << endl;
}
else
for (int p = 1 ; p < length; p++)
{
if (newnode -> shortlink -> num == x)
{
temp = newnode -> shortlink;
number = temp -> longlink -> num;
newnode -> shortlink = newnode -> shortlink -> shortlink;
delete temp;
length--;
}
else
newnode = newnode -> shortlink;
}