Tracing SortedLinkedList
SortedLinkedList<T> keeps its real nodes in ascending order between two sentinels, head and tail, that hold no user value.
Solution
After add(9):
head ───▶ [ ░░░ ] ◀──▶ [ 9 ] ◀──▶ [ ░░░ ] ◀─── tail
After add(4):
head ───▶ [ ░░░ ] ◀──▶ [ 4 ] ◀──▶ [ 9 ] ◀──▶ [ ░░░ ] ◀─── tail
After add(12):
head ───▶ [ ░░░ ] ◀──▶ [ 4 ] ◀──▶ [ 9 ] ◀──▶ [ 12 ] ◀──▶ [ ░░░ ] ◀─── tail
After remove(9):
head ───▶ [ ░░░ ] ◀──▶ [ 4 ] ◀──▶ [ 12 ] ◀──▶ [ ░░░ ] ◀─── tail
After add(7):
head ───▶ [ ░░░ ] ◀──▶ [ 4 ] ◀──▶ [ 7 ] ◀──▶ [ 12 ] ◀──▶ [ ░░░ ] ◀─── tail