can you tell me how many pointers must be change to insert a value at the end of the list?
Printable View
can you tell me how many pointers must be change to insert a value at the end of the list?
13 of course. :rolleyes:
That is If the double linked list has an end... In most cases it is used as cyclic so you get get to any node starting to any node and moving any direction...
In this case adding to the end has no difference from adding to any other location
2 if it really is the end (i.e. it actually has an end)
4 if it is in the middle, or is a ring-list.
It also depends if you count initializing the end pointer to nil, because then it would be 3, not 2.
Also, if the list is empty, inserting a link at the "end" would involve 1 or 3 assignments, depending on how you look at it.
10 if it is the end and you count in binary
Right . . .
Anyway it sounds like a homework question. The OP didn't say "how do I insert a link at the end of a linked list".