logo

Crowdly

Browser

Додати до Chrome

Read carefully the following program: import java.util.Scanner; public cla...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Read carefully the following program:

  1. import java.util.Scanner;

  2. public class sum

  3. {

  4.   public static void main(String[] args)

  5.   {

  6.     Scanner input = new Scanner(System.in); 

  7.     int n = input.nextInt();

  8.     int sum = 0;

  9.     for (int i = 1; i <= n; i++) {

  10.       sum = sum + i;

  11.     }

  12.     System.out.println(sum);

  13.   }

  14. }

In Big O notation, what is the run-time of this algorithm as a function of the size of the input n?

0%
0%
0%
0%
0%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.kent.ac.uk?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome