Tải bản đầy đủ (.pdf) (10 trang)

Tài liệu Thuật toán Algorithms (Phần 54) doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (55.93 KB, 10 trang )

EXHAUSTIVE SEARCH
523
process node x, visit x, then visit each son of x, applying this visiting procedure
recursively and returning to node x after each son has been visited, ending up
at node x. This tour traverses every edge in the spanning tree twice, so its
cost is twice the cost of the tree. It is not a simple tour, since a node may be
visited many times, but it can be converted to a simple tour simply by deleting
all but the first occurrence of each node. Deleting an occurrence of a node
corresponds to taking a shortcut past that node: certainly it can’t increase
the cost of the tour. Thus, we have a simple tour which has a cost less than
twice that of the minimum spanning tree. For example, the following diagram
shows a minimum spanning tree for our set of sample points (computed as
described in Chapter along with a corresponding simple tour.
This tour is clearly not the optimum, because it self-intersects. For a large
random point set, it seems likely that the tour produced in this way will
be close to the optimum, though no analysis has been done to support this
conclusion.
Another approach that has been tried is to develop techniques to im-
prove an existing tour in the hope that a short tour can be found by ap-
plying such improvements repeatedly. For example, if we have (as above)
a Euclidean traveling salesman problem where graph distances are distances
524 CHAPTER 39
between points in the plane, then a self-intersecting tour can be improved by
removing each intersection as follows. If the line intersects the line CD,
the situation can be diagramed as at left below, without loss of generality.
But it follows immediately that a shorter tour can be formed by deleting AB
and CD and adding AD and CB, as diagramed at right:
Applying this procedure successively will, given any tour, produce a tour that
is no longer and which is not self-intersecting. For example, the procedure
applied to the tour produced from the minimum spanning tree in the example
above gives the shorter tour AGOENLPKFJMBDHICA. In fact, one of the


most effective approaches to producing approximate solutions to the Euclidean
traveling salesman problem, developed by S. Lin, is to generalize the procedure
above to improve tours by switching around three or more edges in an existing
tour. Very good results have been obtained by applying such a procedure
successively, until it no longer leads to an improvement, to an initially random
tour. One might think that it would be better to start with a tour that is
already close to the optimum, but Lin’s studies indicate that this may not be
the case.
The various approaches to producing approximate solutions to the travel-
ing salesman problem which are described above are only indicative of the
types of techniques that can be used in order to avoid exhaustive search. The
brief descriptions above do not do justice to the many ingenious ideas that
have been developed: the formulation and analysis of algorithms of this type
is still a quite active area of research in computer science.
One might legitimately question why the traveling salesman problem and
the other problems that we have been alluding to require exhaustive search.
Couldn’t there be a clever algorithm that finds the minimal tour as easily
and quickly as we can the minimum spanning tree? In the next chapter
we’ll see why most computer scientists believe that there is no such algorithm
and why approximation algorithms of the type discussed in this section must
therefore be studied.
SEARCH
525
Exercises
1.
2.
3.
4.
5.
6.

7.
8.
9.
10.
11.
Which would you prefer to use, an algorithm that requires steps or
one that requires steps?
Does the “maze” graph at the end of Chapter 29 have a Hamilton cycle?
Draw the tree describing the operation of the exhaustive search procedure
when looking for a Hamilton cycle on the sample graph starting at vertex
B instead of vertex A.
How long could exhaustive search take to find a Hamilton cycle in a graph
where all nodes are connected to exactly two other nodes? Answer the
same question for the case where all nodes are connected to exactly three
other nodes.
How many calls to visit are made (as a function of by the permutation
generation procedure?
Derive a nonrecursive permutation generation procedure from the pro-
gram given.
Write a program which determines whether or not two given adjacency
matrices represent the same graph, except with different vertex names.
Write a program to solve the knapsack problem of Chapter 37 when the
sizes can be real numbers.
Define another cutoff rule for the Euclidean traveling salesman problem,
and show the search tree that it leads to for the first six points of our
sample point set.
Write a program to count the number of spanning trees of a set of N
given points in the plane with no intersecting edges.
Solve the Euclidean traveling salesman problem for our sixteen sample
points.


40. NP-complete Problems
The algorithms we’ve studied in this book generally are used to solve
practical problems and therefore consume reasonable amounts of re-
sources. The practical utility of most of the algorithms is obvious: for many
problems we have the luxury of several efficient algorithms to choose from.
Many of the algorithms that we have studied are routinely used to solve actual
practical problems. Unfortunately, as pointed out in the previous chapter,
many problems arise in practice which do not admit such efficient solutions.
What’s worse, for a large class of such problems we can’t even tell whether or
not an efficient solution might exist.
This state of affairs has been a source of extreme frustration for pro-
grammers and algorithm designers, who can’t find any efficient algorithm for
a wide range of practical problems, and for theoreticians, who have been un-
able to find any reason why these problems should be difficult. A great deal
of research has been done in this area and has led to the development of
mechanisms by which new problems can be classified as being “as difficult as”
old problems in a particular technical sense. Though much of this work is
beyond the scope of this book, the central ideas are not difficult to learn. It
is certainly useful when faced with a new problem to have some appreciation
for the types of problems for which no one knows any efficient algorithm.
Sometimes there is quite a fine line between “easy” and “hard” problems.
For example, we saw an efficient algorithm in Chapter 31 for the following
problem: “Find the shortest path from vertex to vertex y in a given weighted
graph.” But if we ask for the longest path (without cycles) from to we
have a problem for which no one knows a solution substantially better than
checking all possible paths. The fine line is even more striking when we
consider similar problems that ask for only “yes-no” answers:
527

×