I think we can improve on the delete algorithm. Right now it seems to be complex. Probably the complexity is because you are maintaining the prev reference.
In your algorithm you are forced to maintain the prev reference because you have started from the first node in the list; instead if you start from an imaginary zeroth node then you will not be required to maintain the prev reference.
I think we can improve on the delete algorithm. Right now it seems to be complex. Probably the complexity is because you are maintaining the
prev
reference.In your algorithm you are forced to maintain the
prev
reference because you have started from the first node in the list; instead if you start from an imaginary zeroth node then you will not be required to maintain theprev
reference.