Java: how to use dummy node or mark a node as dummy node

Viewed 3194

A question asking you to delete the middle node in a linked list, only that node is give. The way to solve the problem is copy middle.next.element to middle.element and then delete middle.next by doing middle.next=middle.next.next

There's a special case which is when middle.next is the last node. The answer say that you could mark the middle node as dummy.

I'm not familiar with the idea "dummy". How to mark a node as dummy and how to use a dummy node in other cases?

What about dummy data in general?

1 Answers
Related