Search code examples
javapseudocode

How this Java for loop should look like in pseudocode?


How should I proceed to turn this piece of code into pseudocode?

ArrayList<Integer> check = new ArrayList<Integer>();
ArrayList<Integer> dup = new ArrayList <Integer> ();
ArrayList<Integer> nonDup = new ArrayList <Integer> ();

for (int i : listA) {
    nonDup.add(i);
}
for (int i : listB) {
    nonDup.add(i);
}
for (int i : listA) {
    check.add(i);
}
for (int i : listB) {
    if (check.contains(i)) {
        dup.add(i);
        nonDup.removeAll(duplicates);                   
    }
}

I have no idea how to turn the for loops, add(), contains() and removeAll() methods into pseudocode.


Solution

  • PseudoCode can be whatever you want. Since you or other people can understand what the lines mean.

    You can turn it simple as FOR (your variable value start) TO (your end desired) i++ -

    Basically something that makes people and you mostly understand that it is a For Loop