I have this code and I am trying to work out the time complexity of it when n=2, n=4 and n=6. Can anyone help me? I'm confused as how I do it? Big-O Notation please.
using System;
class TimeComplexityTest
{
public static void Main( string[] args)
{
int n;
Console.WriteLine("Please enter the value of n");
n = Int32.Parse(Console.ReadLine());
Console.Write("\n");
for (int i = 1; i <= 1.5*n; i++)
Console.WriteLine(i);
for (int i = n; i >= 1; i--)
Console.WriteLine(i);
Console.Read();
}
}
nso it is not really relevant what it looks like for particular values ofn- what is relevant is how is scales -- e.g. ifndoubles, does the run time stay approximately the same, does it double, or even quadruple, for instance. This is what the Big O-notation expresses.