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

Mount Everest is higher (then, than) Mont Blanc. (Which is correct grammar)
During which movement in Beethoven's Fifth Symphony do double variations appear? a. Second b. Third c. First d. Fourth
There are 24 offices in a building that contains 4 floors. On average, how many offices are on each floor?
Ancient worship in ancient China can be described as
The value of 9p in £8.90
Need help please! I need the right answer! Choose the answer. Which word best describes the degree of overlap between the two data sets? A. high B. modera
why did the catholic church want to silence Savonarola
Why is most space exploration accomplished with spacecraft that do not have astronauts on board
15) In __________ theory, the true subject and meaning of a dream may have little to do with its apparent story line. a. latent content b. desire c. manifest
Hydrocarbons are separated from each other by a process called cracking distillation. a. True b. False