Escolar Documentos
Profissional Documentos
Cultura Documentos
Question 6: What is the least number of Question 7: What is the least number of colors required
colors required to color the vertices in the to color the vertices in the graph below, so that vertices
graph below, so that vertices which are which are connected by an edge get different colors?
connected by an edge get different colors?
1. The Nearest Neighbor and Cheapest Link algorithms given above are examples of
greedy algorithms
2. A greedy algorithm is one which makes all decisions based on what sems best at
the time, without worrying about the future consequences of that choice.
3. Greedy algorithms tend to be fast
4. But greedy algorithms do not always find the best solution to a given problem
o For example, the nearest neighbor algorithm selects at each step the
cheapest available edge, but usually the route it gives is not the shortest
possible route.
5. One problem that greedy algorithms do solve optimally is the problem of finding
a minimum weight spanning tree in a graph, also called a cheapest connecting
network for that graph.
o That is, given a graph with costs on the edges of that graph, you want to
find the cheapest set of edges which connects all the vertices (nodes, sites)
in that graph.
o The greedy algorithm for this problem says to select at each step the
cheapest edge available such that you don't create a cycle within the edges
you have chosen.
o Question 10: Use the greedy algorithm described above to find a
minimum weight spanning tree in the graph shown above. Indicate
the order in which your algorithm selected the edges to put into your
minimum weight spanning tree.
Turing Machines
1. A Turing machine is a DFA with an attached tape from which it reads its input,
and onto which it can write
2. Turing machines are capable of implementing all algorithms which could be
programmed into a computer
3. However, we can prove that there are some tasks which a Turing machine cannot
perform
o Such as recognizing whether the program on its tape would ever print an
"x"
o Such as recognizing whether the program on its tape has an infinite loop
or not. This problem is called the "Halting problem."
4. A Turing machine is a simple model of computation. As such, we can prove
statements about what is or is not possible on a computer by proving that a Turing
machine can or cannot do it.
5. Question 15: What is the Halting problem
6. Question 16: Is it possible to write a computer program which reads another
program as input and determines whether that program has an infinite loop
or not?