You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ).
The text was updated successfully, but these errors were encountered:
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 ).
The text was updated successfully, but these errors were encountered: