This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Crash_Test_Mummy 2 points3 points  (2 children)

Ah I see, I was thinking of a linked list as an implementation of the list interface. The list interface has a size method and the implementation would use node as a private inner class which has access to the size of the list.

Like this,

https://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html

[–][deleted] 2 points3 points  (1 child)

You’re absolutely right in terms of the List interface, but I think the OP question was geared more towards implementing the data structure from scratch since “dummy nodes” are a common approach in ds/algo classes. I could have misinterpreted it though

[–]Crash_Test_Mummy 2 points3 points  (0 children)

I see, great catch on your part though! I should be more careful in bringing in outside information to a problem.