Computer Science, asked by sivanklu, 9 months ago

1. Question 1 The numbers in the table below are the result of executing an algorithm that has one parameter N, a non-negative integer, and produces sequences of integers as outputs. For values of N from 0 to 5, the algorithm produces the following sequences of numbers as outputs. Determine the algorithm that was used to generate the numbers in this table, and Write it down. Execute it for N = 6, and write down your result. Give your description of the algorithm to a friend who is not a programmer, and ask him or her to execute it for N = 6. What is the sequence of numbers for N = 6? (Give your answer as integers separated by single spaces.)

Attachments:

Answers

Answered by tonytk2001
1

Answer:

18 20 22 24 26 28 30 32 34 36 38 40 42 44

Explanation:

Answered by Jasleen0599
0

The algorithm to a friend who is not a programmer, and ask him or her to execute it for N = 6. What is the sequence of numbers for N = 6? (Give your answer as integers separated by single spaces.)

  • One possible algorithm is as follows:
  1. Output the blank string if N=0.
  2. Print "0 1" if N is 1.
  3. output "0 2 2 3" if N = 2.
  4. Print "0 2 4 3 4 5" if N=3.
  5. Print "0 2 4 6 4 5 6 7" if N = 4.
  6. Print "0 2 4 6 8 5 6 7 8 9" if N=5.
  7. Otherwise, simply output a blank text.
  8. Although that may not be the response they were hoping for, this one is equally valid.
  • (The response they were anticipating was to output the first N even integers beginning with zero, followed by the first N integers beginning with N.)

#SPJ2

Similar questions