CSCI1001 -- Introduction to Computer Science
Part II -- Robert Hochberg


Notes are now complete

March 1 slides on DFA's
March 3 slides on DFA's
March 10 slides, with HW review

Traveling Salesman Problem
( Some notes from class - pdf )
  1. A salesman wishes to start at one city, visit a number of other cities, and end up back where he started.  The cost of travel between each pair of cities is given, and the task is to find the cheapest route which visits all cities.
  2. The brute force approach to solving this problem requires checking 1×2×3×4×...×(n - 1) routes, where n is the number of cities.
  3. So we have some heuristic algorithms for solving this problem.  These heuristic methods run very fast (by computer...) on even several million cities, but they are not guaranteed to give the optimal solutionTSP problem
NP-Complete Problems
  1. The traveling salesman problem is an example of an NP-complete problem
  2. A problem is called NP-complete if:
  3. Other NP-Complete problems include:
  4. NP-Complete problems have the following two characteristics:

Question 6:  What is the least number of colors required to color the vertices in the graph below, so that vertices which are connected by an edge get different colors?
Question 7:  What is the least number of colors required to color the vertices in the graph below, so that vertices which are connected by an edge get different colors?
c1 c2

Greedy Algorithms

  1. The Nearest Neighbor and Cheapest Link algorithms given above are examples of greedy algorithmsmwst
  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
  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.
Deterministic Finite Automata (DFA's)
  1. Also called "Finite State Machines."DFA1
  2. A DFA consists of:
  3. These are "machines" which process an input string and move from state to state as they process the string.
  4. A string is a sequence of symbols.
  5. A language is a set of strings, and the language of a DFA is the set of strings that the DFA accepts.
  6. Some more examples:
he language of the DFA to the right is:
{011, 0011, 1011, 00011, 01011, 10011, 11011, ...},
That is, the set of all strings which end in "011".
dfa2
The language of the DFA to the right is:
{0, 1, 01, 10, 010, 101, 0101, 1010, ...}.
That is, the set of all strings which have no two consecutive symbols the same
dfa3
This DFA, taken from the website:
http://www.netaxs.com/people/nerp/automata/dfa1.gif
accepts all strings which contain an even number of 0s and an even number of 1s.
Another DFA
This DFA accepts the language:
{0, 1, 00, 01, 10, 11, 000, 001, 010, 100, 101, 110, 111, 0000, 0001, ...},
That is, the set of all strings which do not contain "011" as a substring.
dfa6
This DFA accepts the language:
{0, 1, 000, 001, 010, 011, 100, 101, 110, 111, 00000, 00001, 00010, 00011, 00100, ...},
That is, the set of strings with an odd number of symbols.
dfa7
Question 11:  What is the language of the DFA shown to the right?
dfa4
Question 12:  What is the language of the DFA shown to the right?
dfa5

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
  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?