maljoh7655 maljoh7655
  • 03-01-2020
  • Computers and Technology
contestada

Give pseudocode for an algorithm that removes all negative values from an array, preserving the order of the remaining elements.

Respuesta :

Algorithm
Algorithm Algorithm
  • 05-01-2020

Answer:

Begin.

WRITE  ''enter test array''

READ test array

test [ ] = new_int [ ] { enter test array here, separated by comma}

int [ ] positives = Arrays.stream(test). filter(x -> x >= 0).toArray();

System. out. println( " Positive array");

for (int i : positives) {

      System.out.print(i+ "\t");  }

WRITE  positive array

End

Explanation

The pseudocode for the  alogirithm has been simplified above, it is implemented in Java 8

Answer Link

Otras preguntas

Describe where is the fertile crescent located where mesopotania located
a heartbeat takes 0.8 seconds how many seconds is this written as a fraction
A company sells cookies in 250-gram packs. When a particular batch of 1,000 packs was weighed, the mean weight per pack was 255 grams and the standard deviation
Mrs Frazier is making costumes for the school play. Each costume requires 0.75 yards of fabric. She bought 6 yards of fabric. How many costumes can Mrs Frazier
what is the value the 1 in 214,278,216
complete the standard form of the equation -4y=3-2y.
the product of 4 and a number x is at least 21
Which of the following would be the most effective long-term solution to fighting desertification in the Sahel? a. planting trees throughout the Sahel b. cons
Which of the following was NOT a strong state by the mid 1400's
Democracy was first practiced in which part of the world?