-3

I am learning linked list in c and c++ however I am stuck trying to understand why the prev and next pointer data types are nodes. Could you please explain to me why it is a node pointer rather one of the predefined data types?

Ray
  • 1

1 Answers1

1

So you have a node. You ask "Who's next behind you?", and it points to the node behind him.

Now you want to ask that thing who's next behind them, but you can only do so if they are a node with that .next() (or similar) method, which points to the next. If it were an int, it couldn't do that.

So you need nodes as wrappers around whatever it is you want to store, in order to navigate through the linked list.

LucasFA
  • 33
  • 4