Files
java-interview-lab/linked-list/output/08-legacy-bugs.txt
T

15 lines
611 B
Plaintext

Two defects in the 2015 programs, reproduced
============================================
2015 DoublyLinkedList: insertAtLast(1), insertAtLast(2), insertAtLast(3), then insertAfter(4, position 3)
Forward: 1 2 3 4
Reverse: 3 2 1
last.data = 3 (the new node 4 is the real last node, but 'last' was never moved)
deleteLast() returned 3; forward now: Forward: 1 2
it should have removed only 4 and returned 4; instead both 3 and 4 are gone and the caller saw only the 3.
the DoublyLinkedList in this module, same operations:
forward: [1, 2, 3, 4]
backward: [4, 3, 2, 1]
removeLast() returned 4