If they try to delete from the right subtree instead, then they get 5 points of partial credits follows:
If the student incorrectly said that the first invalid node is the root of the tree, which is 100, then the following answers become correct for parts b and c and the student should receive full credit if they answered as follows:
Here is the original tree: --100-- / \ 40 200 / \ / \ 20 60 150 400 / \ 125 175 / 160
--100--- ---150--- right rotation / \ left rotation / \ -------------> 40 150 ------------> 100 200 / \ / \ / \ / \ 20 60 125 200 40 125 175 400 / \ / \ / 175 400 20 60 160 / 160
node->blink = new_node; node->blink->flink = new_node;
The problem with the second statement in the above code is that it is trying to set the node's predecessor to point to new_node. However, the first statement wiped out the pointer to the node's predecessor node, so the second statement is actually making new_node's flink point to new_node. Similarly the following code is problematic:
node->blink = new_node;
new_node->blink = node->blink;
The second statement is trying to make new_node's blink point to node's
predecessor node but the first statement wiped out the pointer to this
predecessor node. As a result the second statement is actually making
new_node point back to itself.