title: How can I determine Time and Space Complexity of the below program?
body: <p>I just wrote a code regarding array rotation while studying for Data Structure. I needed to know how I can improve below program by measuring time and space complexity. </p>
  
  <p>Program for array rotation.
  Rotation of the array by 2 will make array</p>
  
  <p>1,2,3,4
  Input</p>
  
  <p>3,4,1,2
  Output</p>
  
  <pre><code>  public class Program
      {
  
          public static void Main(string[] args)
          {
              int arrayCount = 0;
              int rotate = 2;
          int []answer = new int[4];
  
              for (int i = 0; i &lt; answer.Length; i++)
              {
                  answer[i] = Convert.ToInt32(Console.ReadLine());
              }
              arrayCount = answer.Count();
              ArrayRotation.displayRotatedArray(answer, rotate, arrayCount);
              ArrayRotation.printArray(answer, arrayCount);
              Console.ReadKey();
          }
      }
  
   public static class ArrayRotation
      {
          public static void displayRotatedArray(int []temp, int rotate, int count)
          {
  
             int c = rotate;
              int d = rotate;
              int[] firstOccurenceArray = new int[rotate];
  
                  for (int g = 0; g &lt; rotate; g++)
                  {
                      int num = g;
                      firstOccurenceArray[g] = temp[g];
                  }
                  for (int i = 0; i &lt; temp.Length - c; i++)
                  {
                      temp[i] = temp[rotate];
                      rotate++;
                  }
              for (int k = 1; k &lt; d + 1; k++)
              {
                  temp[count - k] = firstOccurenceArray[c - 1];
                  c--;
              }
          }
          /* utility function to print an array */
         public static void printArray(int[] temp, int size)
          {
              for (int i = 0; i &lt; size; i++)
                  Console.Write( temp[i] + " ");
          }
      }
  </code></pre>