Bug in Programming Interviews Exposed?
- by Sam
Hi,
I could not find an errata for the 2nd edition of this book. My question concerns the if-statement in the following piece of code.
void removeHead (Node ** head) {
Node * temp;
if (!(*head)) {
temp = (*head)->next;
delete *head;
*head = temp;
}
}
So I understand that the point of the if-statement is to check if the Node is null. However by adding an additional "!" to the evaluation, wouldn't this negate the false value of null? Would it be correct to change it to something like:
if (*head) { ... }
Also if anyone knows where I can find an official errata for the 2nd edition that would be great.
Thanks,
Sam