can you tell me how many pointers must be change to insert a value at the end of the list?
can you tell me how many pointers must be change to insert a value at the end of the list?
13 of course.
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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
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".
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.