CJCoding With Joseph
15free / daySign inCreate account

A node in the middle of a doubly linked list can unlink itself, because it can see both of its neighbours. No second cursor trailing one node behind is needed, which is the big advantage over a singly linked list. The first and last nodes are special cases, and they are already handled by calling removeFirst() and removeLast().

Requirements: 1. remove(int value) removes the first node holding value and returns true, or returns false when no node holds it. 2. For a middle node, make the node before it point forward past it, and make the node after it point back past it. 3. Lower size by one for a middle node. The two given helpers already do that for the ends.

The DNode class is provided. Do not rename it and do not add public to it, because a Java source file may contain only one public class.

Do NOT write a main method.

Expected output

true
10 -> 30 -> 40 -> null
40 -> 30 -> 10 -> null
3
true
10 -> 40 -> null
40 -> 10 -> null
2

= newline. The output ends with a newline, so print one after the last line.

Hints3 available
Topics
Data Structures & AlgorithmsLinked Lists
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.