A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display true if the value target appears in the list more than once and to display false otherwise. The algorithm uses the variables position and count. Steps 4 and 5 are missing. Step 1: Set count to 0 and position to 1. Step 2: If the value of the element at index position is equal to target, increase the value of count by 1 Step 3: Increase the value of position by 1 Step 4: (missing step) Step 5: (missing step) Which of the following could be used to replace steps 4 and 5 so that the algorithm works as intended? A) Step 4 Repeat steps 2 and 3 until the value of position is greater than n. Step 5 If count is greater than or equal to 2, display true. Otherwise, display false. B) Step 4 Repeat steps 2 and 3 until the value of position is greater than n. Step 5 If count is greater than or equal to position, display true. Otherwise, display false. C) Step 4 Repeat steps 2 and 3 until the value of count is greater than 2. Step 5 If position is greater than or equal to n, display true. Otherwise, display false. D) Step 4 Repeat steps 2 and 3 until the value of count is greater thann. Step 5 If count is greater than or equal to 2, display true. Otherwise, display false.

Respuesta :

Lanuel

The option which could be used to replace steps 4 and 5 so that the algorithm works as intended is: option D.

What is an algorithm?

An algorithm can be defined as a standard formula (procedures) which is made up of a set of finite steps and instructions that are executed on a computer system, so as to enable a software solve a particular problem under appropriate conditions.

In this scenario, the options which could be used to replace steps 4 and 5 so that the algorithm works as intended by the programmer are:

  • Step 4: Repeat steps 2 and steps 3 until the value of position is greater than n.
  • Step 5: If count is greater than or equal (≥) to 2, display true. Otherwise, display false.

Read more on algorithm here: brainly.com/question/24793921

#SPJ1