answersLogoWhite

0

It sounds like you're using Java, so instead of pseudo-code, I'll give you the actual code.

LinkedList<Integer> l;

// Let's assume you have a bunch of Integer values in this list.

for (int i = 0; i < l.size(); i++){

int n = l.get(i);

boolean prime = true;

for (int i = 2; i < n; i++){

if (n % i == 0){

prime = false;

break;

}

}

if (prime){

l.remove(i);

i--;

}

}

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: What is the pseudo code to delete prime numbers from linked-list?
Write your answer...
Submit
Still have questions?
magnify glass
imp