Given a doubly linked list containing N nodes, the task is to delete all nodes from the list which are prime.
Input: List = 15 <=> 16 <=> 6 <=> 7 <=> 17
Output: Final List = 15 <=> 16 <=> 6
Input: List = 5 <=> 3 <=> 4 <=> 2 <=> 9
Output: Final List = 5 <=> 4 <=> 9
Below is the implementation of above idea:
Original List: 15 16 7 6 17 Modified List: 15 16 6
Time Complexity: O(N), where N is the total number of nodes.
- Delete all the even nodes from a Doubly Linked List
- Delete all the nodes from the doubly linked list that are greater than a given value
- Delete all the nodes from a doubly linked list that are smaller than a given value
- Delete all nodes from the doubly linked list which are divisible by K
- Product of all prime nodes in a Doubly Linked List
- Delete all Non-Prime Nodes from a Singly Linked List
- Delete all Prime Nodes from a Singly Linked List
- Delete all Prime Nodes from a Circular Singly Linked List
- Delete a node in a Doubly Linked List
- Delete all occurrences of a given key in a doubly linked list
- Delete a Doubly Linked List node at a given position
- Delete N nodes after M nodes of a linked list
- Rotate Doubly linked list by N nodes
- Sum of all nodes in a doubly linked list divisible by a given number K
- Delete alternate nodes of a Linked List
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.