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.
Related
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.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Given a machine that can compute the kth smallest item of an Array A in 𝑂(√𝑛) time. Find a recursive function that can sort A in linear time corresponding to n which is the length of A.
First I tried to optimize some of the sorting algorithms I knew using this new property but the best I could do was O(n^3/2) and currently I'm wondering whether if it is possible or not.
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
I am looking for an optimal seat allocation algorithm, such that for example, if i have a cinema with capacity 100, and n groups of people, i want to choose the right groups that will fill in as maximum seats as possible.
The only thing that will work is brute force, but I'm sure there must be cleverer ways to do that. Any ideas?
This is a special case of the Knapsack problem known as the Subset Sum problem. There is a lot of work already done on this so the wiki article is a good jumping off point discussing many possible algorithms. The correct choice in algorithm will depend on the sort of data you’re operating on.
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
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.