Upper bound for an algorithm

In summary, the problem is to show that after O(n log(n)) iterations, all the balls have weights greater than one. This can be easily shown if the subsets chosen by the opponent are always of size 1 or n. The order of the choices does not matter as the weights are multiplied and commutative. The function \phi, which is the average of the weights, can be used to show how it is increased in each iteration but this approach was not successful. Another way is to order the subsets so that the average of the elements is always the smallest, which will result in each element being multiplied by 2 after n iterations. However, this may not be the optimal strategy. Finally, the big O notation means that
  • #1
OfirD
3
0
there are n balls of weight 1/n.
an opponent choose each time a subset of balls that each one has weight less than 1. then each ball in this set, its weight is multiplied by [tex]1+\frac{1}{|S|}[/tex] where S is the set of balls that the opponent chose.
I need to show that for each choice of subsets, after O(n log(n)), all the balls have weights greater than one.

this is easy to show for example, if the subsets are always of size 1, or of size n. also there is no real importance to the order of the choices of the subsets, because eventually this is just multiplication of the weight values, and so this is commutative.
I tried to show this by defining the function [tex]\phi[/tex] which is the average of the weights, and see how it is increased in each iteration, but didn't get very far.

another way I thought of is to show, that if I order the sets so that each time I choose the set that the average of its elements is the smallest, then after n iterations, each elements is multiplied by 2. this is true for the choices of always n balls, and of always 1 ball.
 
Physics news on Phys.org
  • #2
OfirD said:
there are n balls of weight 1/n.
an opponent choose each time a subset of balls that each one has weight less than 1. then each ball in this set, its weight is multiplied by [tex]1+\frac{1}{|S|}[/tex] where S is the set of balls that the opponent chose.
I need to show that for each choice of subsets, after O(n log(n)), all the balls have weights greater than one.

Let’s take n=6 for example. Am I allowed to make O(n log(n)) = 4.66 turns in the game? Should I round it up to 4 or 5?

OfirD said:
this is easy to show for example, if the subsets are always of size 1, or of size n.

Again, let’s take n=6 for example.
If the subsets are always of size 1, game will have 6 iterations
If the subsets are always of size n, game will have 5 iterations
Both numbers are larger than 4.66, what is, as far as I understand, the predicted number of turns.

Big O notation assumes n approaches infinity and any coefficients should be omitted. Is it the case in your problem? I will assume this is the case; otherwise problem description does not make too much cense.

Let’s look at the following strategy.
Step 1. Opponent chooses balls 1 and 2.
Step 2. Balls 3 and 4.
Step 3. Balls 5 and 6.
Etcetera: two balls per step, until they run out.
Then, opponent starts over and chooses balls 1,2,3,… again – one ball at a time.

Please see this spreadsheet for demonstration of this algorithm for n=8.

http://ganymed.ca/temp/Upper_bound_problm_8.xls

As you can see, the number of steps is 12. The run time of this algorithm is O(1.5 * n), what is equal to O(n). So, your upper boundary looks correct.

I will have to think about your problem.

By the way, in my chart, yellow fields are for user input; white fields are calculated. Field B1 is for number n. Chart of yellow fields should be filled of 1’s and blanks. 1 will indicate ball is selected in this step. White numbers below are the weights of the balls. Each column corresponds to one ball; row corresponds to one iteration.
 
  • #3
I assume |S| in your formula is total weight of selected balls, not the count of selected balls, correct?
 
  • #4
Thanks, but I already found a solution. the potential function should be the multiplication of the weights and not their sum.
any way, the big O notation means that there is a constant C and and a natural number N, such that for all n>N , C n log(n) is an upper bound
 
  • #5
OfirD said:
Thanks, but I already found a solution.

Me too.
Maximum number of game iterations is 2*n-2, correct?
So, complexity is O(n).
 

1. What is an upper bound for an algorithm?

An upper bound for an algorithm is the maximum amount of time that the algorithm will take to solve a problem, regardless of the input size. It is a theoretical measure of the algorithm's efficiency and can be used to compare different algorithms that solve the same problem.

2. How is an upper bound calculated for an algorithm?

An upper bound can be calculated by analyzing the algorithm and determining the maximum number of steps it will take to solve a problem of a given size. This can be done through mathematical analysis or by measuring the algorithm's performance on different input sizes.

3. Why is it important to know the upper bound for an algorithm?

Knowing the upper bound for an algorithm can help determine whether it is a suitable solution for a particular problem. It can also be used to compare different algorithms and choose the most efficient one. Additionally, it can provide insights into how the algorithm may perform in real-world situations.

4. Can an algorithm have multiple upper bounds?

Yes, an algorithm can have multiple upper bounds. This is because the upper bound is a theoretical measure and can vary depending on the analysis method used or the input size. However, the tightest upper bound is typically considered the most accurate representation of an algorithm's efficiency.

5. How does the upper bound relate to the worst-case scenario?

The upper bound is often used to represent the worst-case scenario for an algorithm. This means that the algorithm's performance will never exceed the upper bound, regardless of the input size or other factors. Therefore, the upper bound can be used to ensure that the algorithm will always perform efficiently, even in the worst-case scenario.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
11
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
Replies
2
Views
328
  • Calculus and Beyond Homework Help
Replies
4
Views
502
  • Calculus and Beyond Homework Help
Replies
1
Views
505
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
960
Back
Top