Calculating Complexity of a Problem-Calculation

  • Thread starter kioria
  • Start date
  • Tags
    Complexity
In summary, the conversation discusses the problem of calculating distances between points in cartesian coordinate format and the number of distance calculations executed by a program for an input of N points. The use of Big-Oh notation is also discussed, with the goal of finding a function g(N) that f(N) is asymptotic to. The conversation suggests counting the number of loops and operations in the program to find the values of g(N) and a constant value C to make the inequality f(N) ≤ C*g(N) true.
  • #1
kioria
54
0
I have been given an assignment, a small one, which simply takes in number of points in cartesian coordinate format: (x, y) - then - the assignment specified that the program needed to calculate distances of every permutation possible - then return with the set(s) of points that had the shortest distance.

The problem given is simple, and I have coded in C - works perfectly OK.

But here's the problem:

What is the number of distance calculations executed by your program for an input instance of "N" points, as a function of "N", expressed in Big-Oh notation? JUSTIFY your answer.

I know that my program (which I think is efficient enough at this stage) calculates in this many steps:

[tex]f(x) = \sum_{n=2}^N (x - 1)[/tex]

I also know that Big-Oh notation is something that f(x) is asymptotic to. For example:

[tex]g(x) = O(f(x)) = c.f(x) = c.\sum_{n=2}^N (x - 1)[/tex]

Is this correct way of looking at the Big-Oh notation? How would I find the value of c?

Thanks

 
Last edited:
Computer science news on Phys.org
  • #2
What's x? Presumably the complexity of your program, for an input of size N is
f(N) = [some function of N]
so I don't see where x comes into the picture.

Ultimately you want to be able to say that
f(N) = O(g(N))

meaning that there is some function g(N) such that your function
f(N) [itex]\leq[/itex] C*g(N)
whenever N > k for some constants C and k of your choosing (k might be 0). C and k are whatever constants you need to make that inequality true. Depends on what f(N) is, so you need to get your f(N) into a more useful form.

(As a start, count how many times your program loops as a function of N, and how many operations it performs per loop.)
 
  • #3
I messed up with my x's and N's, the top line should really be f(N). I am having trouble finding g(N) and the constant value C.
 

Related to Calculating Complexity of a Problem-Calculation

1. What is the purpose of calculating the complexity of a problem-calculation?

The purpose of calculating the complexity of a problem-calculation is to determine the amount of time and resources needed to solve a problem. This helps in identifying the most efficient algorithm or approach to solving the problem.

2. How is the complexity of a problem-calculation measured?

The complexity of a problem-calculation is measured by the number of operations or steps required to solve the problem. This is typically denoted as "Big O" notation, which represents the worst-case scenario for the time and space complexity of an algorithm.

3. What factors affect the complexity of a problem-calculation?

The complexity of a problem-calculation is affected by the size of the input data, the efficiency of the algorithm used, and the type of problem being solved. Additionally, the presence of nested loops or recursive calls can also impact the complexity.

4. How does the complexity of a problem-calculation impact its performance?

The complexity of a problem-calculation directly impacts its performance. A problem with a higher complexity will take longer to solve and require more resources, whereas a problem with a lower complexity will be solved more quickly and with fewer resources.

5. Can the complexity of a problem-calculation be reduced?

Yes, the complexity of a problem-calculation can be reduced by using more efficient algorithms or optimizing existing algorithms. However, some problems inherently have a high complexity and cannot be significantly reduced. In these cases, it is important to find the most efficient solution possible.

Similar threads

Replies
14
Views
2K
  • Calculus and Beyond Homework Help
Replies
5
Views
332
  • Math POTW for Graduate Students
Replies
1
Views
938
Replies
1
Views
511
Replies
4
Views
857
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Topology and Analysis
Replies
4
Views
359
Replies
2
Views
1K
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
Back
Top