javascript-algorithms icon indicating copy to clipboard operation
javascript-algorithms copied to clipboard

set tail as newNode if currentNode is the tail

Open xyn22 opened this issue 2 years ago • 0 comments

closes #1016 closes #1004

To reproduce

  1. Populate the list normally, insert few values.
  2. call insert with rawIndex equals to last node index + 1 (exactly where new node would fit)

Expectation

this.tail should point to the last added value as it has rawIndex as previous tail + 1

Behaviour

this.tail points to the previous tail.

Fix

If currentNode is the tail then newNode should be the new tail, as in this scenario currentNode will have newNode as its next

xyn22 avatar Apr 08 '23 02:04 xyn22