Calculating Complexity of a Problem-Calculation

  • Thread starter Thread starter kioria
  • Start date Start date
  • Tags Tags
    Complexity
Click For Summary
SUMMARY

The forum discussion centers on calculating the complexity of a problem involving distance calculations in a Cartesian coordinate system using C programming. The user seeks to express the number of distance calculations as a function of "N" points in Big-Oh notation. The discussion highlights the importance of defining the function f(N) and finding a suitable g(N) to establish the relationship f(N) = O(g(N)), while also determining the constants C and k necessary for this relationship.

PREREQUISITES
  • Understanding of Big-Oh notation and asymptotic analysis
  • Familiarity with Cartesian coordinates and distance calculations
  • Proficiency in C programming language
  • Knowledge of algorithm complexity and loop analysis
NEXT STEPS
  • Learn how to derive functions for algorithm complexity in Big-Oh notation
  • Study the principles of loop analysis in C programming
  • Explore examples of distance calculation algorithms and their complexities
  • Research methods for determining constants in asymptotic notation
USEFUL FOR

Students, software developers, and computer scientists interested in algorithm analysis, particularly those working with distance calculations and complexity in programming.

kioria
Messages
54
Reaction score
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:

f(x) = \sum_{n=2}^N (x - 1)

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

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

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
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) \leq 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.)
 
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.
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 0 ·
Replies
0
Views
553
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K