Question about wording of an algorithm-complexity problem

  • Thread starter s3a
  • Start date
In summary, the conversation discusses a problem involving the computation of a series and the requirement that the number of steps should be of order n. The conversation also delves into the use of big O notation and its relation to big theta notation. The speaker is seeking clarification on whether the sought algorithm has complexity O(n) or if it is also \Omega(n) and \Theta(n).
  • #1
s3a
818
8
Hello to everyone who's reading this.

Here is the problem whose wording I'd like to focus and elaborate on (instead of actually solving the problem, which I've been told I have already done so, successfully), where the first of the two parts is underlined, and the second of the two parts is italicized.:

1. Homework Statement

"Compute 1/0! + 1/1! + . . . + 1/n!, for the non-negative integer n, with the additional requirement that the number of steps (i.e., the number of assignments performed during the execution) should be of order n (i.e., not greater than Cn for some constant C)."

Homework Equations


I:
1/0! + 1/1! + . . . + 1/n!, for a non-negative integer n

II:
Let f and g be functions from the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is O(g(x)), if there are positive constants C and k, such that |f(x)| <= C |g(x)|, whenever x > k.

III:
Let f and g be functions from the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is Ω(x), if there are positive constants C and k, such that |f(x)| >= C |g(x)|, whenever x > k.

IV:
Let f and g be functions from set of integers or the set of real numbers to the set of real numbers. We say that f(x) is Θ(g(x)) if f(x) is O(g(x)) and f(x) is Ω(g(x)).

The Attempt at a Solution


I believe "not greater than" is equivalent to "less than or equal to." So, the "i.e., not greater than Cn, for some constant C" part should be equivalent to saying "less than or equal to Cn, for some constant C" and therefore "O(n)," right?

While that doesn't seem incorrect to me, it seems to be an incomplete truth, and I just wanted to make sure that I am right about it being an incomplete truth. Basically, is it the case that the algorithm sought is Θ(n) (in addition to being O(n) and Ω(n), by definition of the big theta notation)? By the way, should definition IV be an "if and only if"? That is, should IV read "Let f and g be functions from set of integers or the set of real numbers to the set of real numbers. We say that f(x) is Θ(g(x)) if and only if f(x) is O(g(x)) and f(x) is Ω(g(x))."? I get that, in practice, one would find that a function is

I get that the big O notation is focused on, since the worst-case complexity of an algorithm is, generally, what's most important, but I just wanted to see if what I'm thinking is correct or not, so any input would be GREATLY appreciated!
 
Physics news on Phys.org
  • #2
s3a said:

The Attempt at a Solution


I believe "not greater than" is equivalent to "less than or equal to." So, the "i.e., not greater than Cn, for some constant C" part should be equivalent to saying "less than or equal to Cn, for some constant C" and therefore "O(n)," right?

While that doesn't seem incorrect to me, it seems to be an incomplete truth, and I just wanted to make sure that I am right about it being an incomplete truth. Basically, is it the case that the algorithm sought is Θ(n) (in addition to being O(n) and Ω(n), by definition of the big theta notation)? By the way, should definition IV be an "if and only if"? That is, should IV read "Let f and g be functions from set of integers or the set of real numbers to the set of real numbers. We say that f(x) is Θ(g(x)) if and only if f(x) is O(g(x)) and f(x) is Ω(g(x))."? I get that, in practice, one would find that a function is

I get that the big O notation is focused on, since the worst-case complexity of an algorithm is, generally, what's most important, but I just wanted to see if what I'm thinking is correct or not, so any input would be GREATLY appreciated!

Well, the assignment is to come up with an algorithm that has complexity [itex]O(n)[/itex]. It might also be the case that the algorithm you come up with is [itex]\Omega(n)[/itex] and [itex]\Theta(n)[/itex] (probably so). The situation where it's nice to consider both [itex]O[/itex]-complexity and [itex]\Omega[/itex]-complexity is when there are cases where the [itex]O[/itex] complexity greatly over-estimates the complexity. In that case, it's nice to have a lower bound, as well. [itex]\Theta[/itex] is really only used when the [itex]\Omega[/itex] and [itex]O[/itex] complexities are the same (which might be the case for your problem).
 

1. What is an algorithm-complexity problem?

An algorithm-complexity problem is a type of problem in computer science that involves determining the efficiency or performance of an algorithm. This can include evaluating the time and space complexity of an algorithm, as well as analyzing its performance under different inputs and conditions.

2. How is the complexity of an algorithm measured?

The complexity of an algorithm is typically measured using big O notation, which expresses the worst-case time or space complexity of an algorithm in terms of the input size. Other measures of complexity, such as average case or best-case, may also be used depending on the specific problem.

3. What is the importance of understanding algorithm complexity?

Understanding algorithm complexity is crucial for developing efficient and scalable solutions to problems. By analyzing the complexity of an algorithm, we can determine how it will perform as the input size increases, and make informed decisions about which algorithm to use in different scenarios.

4. How can we improve the complexity of an algorithm?

There are several ways to improve the complexity of an algorithm, including optimizing the code for faster execution, using more efficient data structures, and implementing more advanced algorithms. However, it's important to note that improving one aspect of complexity (e.g. time) may result in a trade-off with another aspect (e.g. space).

5. Are there any limitations to measuring algorithm complexity?

Yes, there are some limitations to measuring algorithm complexity. For example, big O notation only provides an upper bound on the complexity and does not account for factors such as hardware limitations or variations in input data. Additionally, different algorithms may have the same complexity but perform differently in practice.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
977
  • Engineering and Comp Sci Homework Help
Replies
3
Views
951
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
971
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
538
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top