This segment runs in O(3n). How do we interpret O(3n)?


Notice: Trying to access array offset on value of type bool in /home/onliiuxo/public_html/wp-content/themes/betheme/functions/theme-functions.php on line 1490

Notice: Trying to access array offset on value of type bool in /home/onliiuxo/public_html/wp-content/themes/betheme/functions/theme-functions.php on line 1495

This segment runs in O(3n). How do we interpret O(3n)?


Notice: Trying to access array offset on value of type bool in /home/onliiuxo/public_html/wp-content/themes/betheme/functions/theme-functions.php on line 1490

Notice: Trying to access array offset on value of type bool in /home/onliiuxo/public_html/wp-content/themes/betheme/functions/theme-functions.php on line 1495

Fx = 0
For x = 1 to x = n where n is a positive integer
Fx = x(x+3)+2
Print x
Next x

This segment runs in O(3n). How do we interpret O(3n)?

Is the following answer correct?

Because of the programming segment in the discussion question above, the value of the input integer will vary from 1 to n. This would make x greater than or equal to 1.

(1, 2, 3,…n)

If x = 1 to x = n where n is a positive integer

x = 1

F(x) = 1(1+3)+2

F(x) = 1(4)+2

F(x) = 4+2

F(x) = 6

If I’m correct, because the segment runs in O(3N), this means that the function will triple with each additional element in the input data set. After the sequence, has looped 3 times, this will come out to 18 and then it would move on to the next.