On algrithms that minimizes maximal load of bins [closed] - algorithm

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
There are n bins and m balls. Balls are with different weights, say ball i has weight w_i. Is there an algorithm that assigns balls into x<n bins so that maximal load of these bins is minimized.

This is equivalent to the multiprocessor scheduling problem, which is NP-complete. In other words: algorithm(s) exist, but they are very slow.

This is a disguised hash function question. i.e. You are looking for an optimal hash function. Check out this page - http://en.wikipedia.org/wiki/Hash_function
Generally you want a random key that you can XOR with w_i then take the result mod n to get the bin number.
Note: I took maximal load to mean number of balls per bin. Hashing of course does not work if you want to minimize the weight of each bin.

Related

n balls and n cups algorithm design [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 days ago.
Improve this question
You are given n balls and n cups. Each cup holds a particular weight, and once a ball is placed in it tells you whether the ball is too heavy or light or just right. You can’t compare the weight of the balls directly. A perfect pairing between balls and cups exist. Design an expected nlogn algorithm to find the pairing. Hint: modify quicksort.
I’ve thought about this problem for a long time with no leads.
Is there a efficient way to compare the weight of two balls, or am I thinking about this wrong? Can someone please give a hint?
If you compare all balls with a single randomly picked cup, you will find the matching ball, and the other balls will be partitioned into those higher and those lower. You can use the matching ball to also partition the cups in a similar way. Then you have essentially randomized quicksort.

EV function for 2048 video game [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What is the best admissible heuristic function for 2048 video game? Please give example of initial state and next state and how to compute the value of the evaluation function?
It is hard (if not impossible) to label an heuristic as "best".
One idea I have in mind is evaluate the heuristic for the current state as the maximum value of all the tiles at this state. And then, that with the higher value is supposed to be better ("closer") to the goal.
And it is admissible because it is never would be lower than the real value (that would mean that the current maximum is not the maximum, and that is not possible).
Probably, you can expand this heuristic with something as: given the current maximum position, is one of its (up to) 4 neighbours of the same value so they can sum up? But that requires a bit more of sophistication in order to keep it admissible.

Is O(nk(log(k))) algorithm same as O(n(log(k))) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I was asked to give an algorithm that was supposed to be O(n(log(k)))
k is the number of arrays and n is the total number of elements in all of these. I had to sort the arrays.
Minus the details I came up with an algorithm that does the job for in klog(k) times the total number of elements. i.e. O(nk(log(k)))
Also in this case k is much smaller than n so it wont be n^2(logn) (in case k and n were almost same)right?
Well, no, it's not the same. If k is a variable (as opposed to a constant) in the complexity expression then O(nk(log(k))) > O(n(log(k))).
That is because there is no constant C such that Cn(log(k)) > kn(log(k)) for every n, k.
The way you describe the question both k and n are input parameters. If that is the case then the answer to your question is
'No, O(n*k *log(k)) is not the same as O(n*log(k))'.
It is not that hard to see that the first one grows faster than the second one, but it is even more obvious if you fix the value of n. Consider n begin a constant say 1. Than it is more obvious that O(k*log(k)) is not the same as O(log(k)).

Algorithmic classification [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to classify the following problem:
I have N empty boxes (ni is the volume of the i-th box, 1 <= i <= N) and M divisible items (mj is the volume of j-th item j, 1 <= j <= M). The total volume of all boxes is exactly equal to the total volume of all items. I need to find a distribution of items among boxes which minimizes the number of item divisions.
I suppose this problem is NP-complete, and is some kind of set coverage problem, but I can't find appropriate variation of it.
The special case N=2 and n_1 = n_2 is exactly the Subset Sum problem
http://en.wikipedia.org/wiki/Subset_sum_problem
since the optimum value of the problem formulated above is 0 if and only if
the instance (viewed as an instance of Subset Sum) has a solution. Hence, the presented problem is indeed NP-hard.

The English Tourist [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
"A tourist want to go from Liverpool to Sydney, visiting a number of other cities in the process.
for each pair of cities, he can travel by car, train or ferry, each option has a Cost and Time.
the goal is to go to syndey,traversing all cities in the process whilst keeping the time and cost to a minimum."
1-how do i verify that this problem is NP? given total time T and total cost C?
i.e: if i have 5 nodes, connected by 4 edges,
each edge has 3 options (car,ferry,train)
each option has Cost and time
how do i process the constraints? do i just try all permutations ?
2-i need guidance on actual solution, i do realize this is a subset of the Minimum spanning tree , but now i have 2 constraints, time and cost..how to tackle that ?
This kind of problem is solved with the Hungarian algorithm

Resources