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

JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
RossRoss
Every question is just a happy little opportunity.
Chat with Ross
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake

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