It seems that the answer to the 10.1.4 is wrong. Checking for tail[Q]+1 == head[Q] is not enough in the case where we have tail[Q] = length[Q] and head[Q] == 1 which will result on an overflow but it will not be detected by the offered solution.
A better solution would be to check if head[Q] == tail[Q] + 1 or ( tail[Q] == length[Q] and head[Q] == 1 ).
It seems that the answer to the 10.1.4 is wrong. Checking for tail[Q]+1 == head[Q] is not enough in the case where we have tail[Q] = length[Q] and head[Q] == 1 which will result on an overflow but it will not be detected by the offered solution. A better solution would be to check if head[Q] == tail[Q] + 1 or ( tail[Q] == length[Q] and head[Q] == 1 ).