52 views

I was referring to this question :

Although I agree with option A (deletion) being better that singly linked list, but what about C (inverting a node)?

| 52 views

considering that invert means interchanging two nodes

in both singly and doubly we use temp node to perform so basically its the same

difference comes in the way we reach that location

in singly wehave to traverse from the begining

and in doubly can be traversed backwards

therefore i feel in this case too doubly is more efficient

correct me if i am wrong
by Boss (10.2k points)
0
I'm really not sure what the statement means in the first place. Because invert generally means just changing the direction of the list.

If we consider your understanding of the statement then yes, both will be the same. And even Doubly will have to traverse to that location. Doubly, like singly has head at the beginning, right? So it just can't start traversing from backwards (can happen if it is circular).
0
but suppose u have used a pointer and traversed for some purpose to the far end of the list and the location to be inverted is near from  the last  then doubly can just traverse backwards while singly has to still move from the beginning

i think this was the logic behind doubly being more efficient in deleting node at a given location than singly linked list

thats what i understood
0
Oh yes I forgot about a pointer already being available. You're right.

But is that what inverting is?
0
am not sure .......what that means

but if assumed as interchanging ,my explanation would match