Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

Algorithm for Deleting a particular node in Circular Doubly Linked List in dfs

  Shared By: Alex Evans    Date: Sep 10    Category: C++ Programming    Views: 7295

Answer:

PROCEDURE DELETE_CD(T, KEY)
[Where pointer ‘T’ is a pointer which is pointing to first in or lasting element and key is the value which we want to delete.]

1. [Checking the value of pointer and traversing the destination]

if (T==HEAD)
while (DATA(T) != KEY)
T <-- RIGHT (T)
else
while (DATA(T) != KEY)
T <-- LEFT (T).

2. [Deleting node from the list].

Q <-- LEFT (T)
RIGHT (Q) <-- RIGHT (T)
LEFT (RIGHT(T)) <-- Q
if (T == HEAD)
HEAD <-- RIGHT (HEAD)
else if (T == P)
P <-- LEFT (P)
Call REMOVE NODE (T).

3. [FINISH]
return.

Share: 
 


Related Topics:

Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: