Add linked-list module: singly and doubly lists with measured costs, reverse, middle, Floyd cycle detection, merge and 5 more interview problems, the 2015 menu programs and a doubly-list bug they exposed (15 tests, 15 transcripts)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6r9iSyHu5qSJMzH2n
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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
|
||||
Reference in New Issue
Block a user