How does this enqueue function work?

The rear points to the last element. What is wanted is to place temp after the current rear, and then move rear to point to the newly placed last element. So, if we were wanting to enqueue 4 to the queue (1, 2, 3), we want:

frontrear

Your solution lets temp cut in front of the current rear, and then moves rear to the cut position. It doesn’t even cut properly, since the item before the rear is still pointing to the original rear. The rear isn’t pointed to the last item anymore, and your queue would thus be in an inconsistent state.

front rear

,你在无垠的海边第一次听到了自己心跳的声音,

How does this enqueue function work?

相关文章:

你感兴趣的文章:

标签云: