Skip to content
Advertisement

Deleting all occurrences in a circular linked list. (java)

I want to implement a method that deletes all occurences of a certain value given as argument.
I created 2 temporary elements and referenced them to the head and I will be browsing the list using them. I was able to write a whole code but I’m not getting any result, I don’t know where the problem is, neither I am getting an error.

Any help would be appreciated.

This is the method (my approach):

JavaScript

An this is the whole class maybe you need to check something:

JavaScript

Advertisement

Answer

your method is running to an infinite loop. Try something like this:

JavaScript

You should handle the corner cases too when the head is the removable element.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement