4

There is a problem asked in contest. I already solved this problem with dynamic programming and its complexity O(n^2). But i am looking for solution with less efficient way. What will be the complexity of this less efficient way. Thanks for the helps.

8
  • 5
    I guess you mean "more efficient way"? Otherwise, its easy to make the algorithm arbitrarily inefficient. Commented Dec 27, 2012 at 9:59
  • i mean less efficent way. I would like to compare their complexity.For instance i am looking for a O(n^3) solution Commented Dec 27, 2012 at 10:03
  • 5
    @mustad: O(n^2) is a subset of O(n^3), so an O(n^2) solution is also an O(n^3) solution. Commented Dec 27, 2012 at 10:45
  • @amit assume Theta(n^3); it's still trivial to make an algorithm arbitrarily slow. Commented Dec 27, 2012 at 10:45
  • By the way, did you know you can sort arrays in Th((3/2)^n)? Commented Dec 27, 2012 at 10:48

2 Answers 2

2

There is a general way to make any dynamic programming solution less efficient. The essence of dynamic programming is to store solutions to sub-problems for reuse.

To make it less efficient in a somewhat reasonable way, get rid of the sub-problem result storage. Instead, recalculate each sub-problem solution whenever you need it.

Sign up to request clarification or add additional context in comments.

Comments

1

Using inefficient data structure with same algorithm can help to have O(n^3). Storing towns in a linked list instead of an array will make algorithm one order less efficient.

To make it even less efficient, it is easier to change algorithm. For example checking of all harbinger changing combinations and using minimal, which is exponential in time.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.