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


Notes are now complete

Slides from 9/20
Slides from 9/27
Slides from 10/4

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

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. Question 10:  Can you build a DFA with one state which accepts all strings?
  5. A string is a sequence of symbols.
  6. A language is a set of strings, and the language of a DFA is the set of strings that the DFA accepts.
  7. Some more examples:
The 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 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

Halting Problem
  1. This material can be found in your book, in the last chapter.
  2. It can also be found at www.wikipedia.org.  Search for "halting problem."
  3. The halting problem asks:  Does there exist a program Halt(program P, input I) which looks at program P, with input I, and asks whether program P will halt if its input is I.
  4. We proved that the program Halt cannot exit.  Because if it did exist, then we would be able to construct another program called "trouble" (name taken from Wikipedia's article) which works as follows:
  5. So the halting problem, to write a program which does what Halt, described above, should do, can never be solved by computers.
  6. This leads to a whole host of problems which computers will never be able to solve, such as
  7. Question 15:  What is the Halting problem
  8. 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?