linked list
[closed]

in Programming in C recategorized by
1,412 views
1 vote
1 vote
closed as a duplicate of: GATE IT 2004 | Question: 13

Let P be a single linked list.Let Q be a pointer to an intermediate node 'X' in the list.What is the worst case time complexity of best known algorithm to delete the node 'X ' from the list

in Programming in C recategorized by
1.4k views

4 Comments

@abhishek Here content of node to which Q is pointing already changed. Hence to need to again point prev of Q to next of Q.
0
0

we need another pointer who will point to previous node of Q

P->next=Q; then again A will point to C

A->C->D...

but for this question we do not have to do  @ Manu Thakur sir ??

0
0
@abhishek why do you need a pointer the the previous node of the node pointedby q? it is written in the question node to be deleted is an intermediate node.

if question is to delete the last node then we need a pointer which will point to the second last node. hence to delete last TC is O(n) and other than last node each node can be deleted in O(1)
2
2

Related questions