First algorithm
Answer (3) O(lg m) times . You just need to do a binary search for the minimum Hamilton tour in a weighted graph. Note that if there is a Hamiltonian tour along the length L in the graph, it makes no sense to check whether there is a Hamiltonian tour along the length L' , where L' > L , since you are interested in the Hamiltonian of the minimum weight of the tour. Thus, at each step of your algorithm, you can eliminate half of the remaining possible tours. Therefore, you will have to call B in your machine O(lg m) times, where m means the total weight of all the edges in the full graph.
Edit:
Second algorithm
I have a small modification of the above algorithm that uses machine O(|E|) times, as some people said that we cannot use binary search in an uncountable set of possible values ββ(and they are probably right): accept all possible subset of edges from the graph, and for each subset - a value that represents the sum of the weights of all the edges from the subset. Allows you to store values ββfor all subsets in an array named Val . The size of this array is 2^|E| . Sort Val in ascending order, and then apply binary search for the minimum path of the Hamiltonian, but this time call a machine that solves Problem B only with values ββfrom the Val array. Since each subset of edges is included in the sorted array, it is guaranteed that a solution will be found. The total number of machine calls is O(lg(2^|E|)) , which is O(|E|) . So, the right choice is (2) O(|E|) times .
Note:
The first algorithm I proposed is probably incorrect, as some people have noted that you cannot use binary search in an uncountable set. Since we are talking about real numbers, we cannot use binary search in the range [0-M]
Rontogiannis aristofanis
source share