#calculating O time complexity of a program

1 messages · Page 1 of 1 (latest)

signal turtle
#

how do i do it

lunar yachtBOT
#

Hey, @signal turtle!
Please remember to /close this post once your question has been answered!

signal turtle
#

i guess i will provide some example code:

public class Area {
     public static void main(String[] args) {
         int width = 7, height = 4;
         int area = width * height;
         
         if (area <= 0)
               System.out.println(“area invalid”);
          else if (area > 35) 
               System.out.println(“area to big”);
          else
                System.out.println(“area just right”);
     }

}```
#

i dont think this is a very good example

#

but how would I calculate big O time complexity of it

bronze wadi
#

calculate it yourself

west gale
#

Just reduce the program to a polynomial function that describes the number of computations required per each additional input.

signal turtle