What Is the Efficiency of Combining Different Algorithm Complexities?

  • Thread starter Thread starter surfy2455
  • Start date Start date
  • Tags Tags
    Algorithms
Click For Summary

Discussion Overview

The discussion revolves around the efficiency of combining different algorithm complexities, specifically analyzing three algorithms with complexities of 200n, 3n², and 2^n - 1. Participants explore how to derive a combined algorithm that is efficient, considering various approaches and interpretations of the problem.

Discussion Character

  • Homework-related
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant proposes a combined algorithm efficiency of O(3log(n)) based on a logarithmic transformation of the individual complexities.
  • Another participant questions the validity of adding the orders of different algorithms, suggesting that the approach of taking term-by-term logs is flawed.
  • A different perspective suggests that the problem may require selecting the algorithm that minimizes runtime based on the value of n, indicating a need to determine ranges of n for each algorithm's efficiency.
  • Further exploration is proposed to find the values of n where one algorithm outperforms another, specifically looking at equations like 200n - 3n² = 0.

Areas of Agreement / Disagreement

Participants express differing views on how to approach the problem, with no consensus on the method for combining algorithm complexities or the interpretation of the question. The discussion remains unresolved regarding the best approach to determine efficiency.

Contextual Notes

Some assumptions about the validity of mathematical transformations and the interpretation of algorithm efficiency are not fully explored, leading to potential gaps in reasoning.

surfy2455
Messages
3
Reaction score
0
*solved

Homework Statement



Lets say we have three algorithms, which include the following complexities 200n, 3n^2, 2^n-1. What would be a combined algorithm which is efficient?

Homework Equations


The Attempt at a Solution



Let me know if I'm on the right path here.

100n+3n^2 + 2^(n-1)
=log(100n)+log(3n^2)+log(2^(n-1))
=[log(100) + log(n)]+[log(3)+log(n^2)]+[(n-1)*log(2)]
=[log(100) + log(n)]+log(n^2)+(n-1),exclude constants
=log(n)+2log(n)+n
=(3log(n)+n)

The efficiency of the combined algorithm is O(3log(n)).
 
Last edited by a moderator:
Physics news on Phys.org
surfy2455 said:

Homework Statement



Lets say we have three algorithms, which include the following complexities 200n, 3n^2, 2^n-1. What would be a combined algorithm which is efficient?

Homework Equations





The Attempt at a Solution



Let me know if I'm on the right path here.

100n+3n^2 + 2^(n-1)
=log(100n)+log(3n^2)+log(2^(n-1))
=[log(100) + log(n)]+[log(3)+log(n^2)]+[(n-1)*log(2)]
=[log(100) + log(n)]+log(n^2)+(n-1),exclude constants
=log(n)+2log(n)+n
=(3log(n)+n)

The efficiency of the combined algorithm is O(3log(n)).

I'm not sure about the logic behind your derivation. Adding together the Orders of different algorithms doesn't make sense to me. Also, in the second line, why have you taken term-by-term logs? The second line won't equal the first.

I could be wrong, but when I look at the problem as stated I imagine that the idea would be to have the program select, based upon the value of n, the algorithm which would minimize the run time. Then you would have different complexities for different ranges of n. The problem would then be to work out the ranges of n that suit each algorithm.
 
gneill said:
I could be wrong, but when I look at the problem as stated I imagine that the idea would be to have the program select, based upon the value of n, the algorithm which would minimize the run time.

I think it is asking for what values of N is Alg(X) the fastest.

Naively, for what values of n (n>=0) is alg(1) < alg(2), alg(2)<alg(1), alg(2)<alg(3), alg (3)<alg(2), alg(3)<alg(1), alg(1)<alg3).
Then just select the best minima.

Starting with, for what vales of n does 200n - 3n^2 = 0
 
surfy2455 said:
*solved

thread can be deleted.

We don't ordinarily delete the contents of threads when they're solved. Other people can sometimes benefit from them.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
2
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
2K