In a DFA, does every state have a transition on every symbol of the alphabet?
You seem to have stumbled on a contentious issue.  Apparently computer scientists like to argue.  I certainly like to argue, so here goes!

My answer is an unequivocal: No.  A deterministic finite automata does not need a transition from every state for every symbol.  The meaning when $\delta(q,a)$ does not exist is simply that the DFA does not accept the input string.

While you can create a definition of DFA that requires that $\delta(q,a)$ does exist, it is simply not the case that a missing transition makes the resulting structure (whatever you call it) in any way nondeterministic as many of the commenters are claiming.  If you are taking a course on automata theory then the next topic will be context-free languages and push-down automata where the distinction between nondeterministic and deterministic automata is crtical, and you need to use the correct definition of non-determinism.

Non-determinism is associated with having more than one legal transition.

I think we all agree with the following Wikipedia definition (which I'll show in just a second is slightly ambiguous):

A deterministic finite automaton $M$ is a 5-tuple, ($Q$, $\Sigma$, $\delta$, $q_0$, $F$), consisting of


a finite set of states ($Q$)
a finite set of input symbols called the alphabet ($\Sigma$)
a transition function ($\delta : Q \times \Sigma \rightarrow Q$)
a start state ($q_0 \in Q)$
a set of accept states ($F \subseteq Q$).


Let $w = a_1 a_2 \cdots a_n$ be a string over the alphabet $\Sigma$. The automaton $M$ accepts the string $w$ if a sequence of states, $r_0, r_1, \ldots, r_n$, exists in $Q$ with the following conditions:


$r_0 = q_0$
$r_{i+1} = \delta(r_i, a_{i+1})$, for $i = 0, \ldots, n−1$
$r_n \in F$.


The ambiguity, and the controversy is over the defintion of the transition function, $\delta$ (number "3" in the first bulleted list.)  We all agree that what differentiates a DFA from an NFA is that $\delta$ is a function rather than a relation.  But is $\delta$ a partial function or a total function?

The definition of the DFA works just fine if $\delta$ is a partial function.  Given an input string, if you reach a state $q_i$ with an input symbol $a_j$ where there is no next state then the automata simply does not accept.

Moreover when you extend this definition to create the definition of push-down automata it will be the case that you must make the distinction that push-down automata with transition functions that are partial functions are classified as deterministic, not nondeterministic.

If the partial function bothers you then here is a trivial transformation that makes $\delta$ a total function.  (This transformation is not like the subset construction algorithm, it adds at most O(1) states, is linear in the original number of states, and can be extended to work with PDAs.  None of those facts is true of the subset construction algorithm.)


add a state $q_{\mathrm{error}}$
for every pair $(q_i, s_j)$ where $\delta$ is undefined, define $\delta(q_i, s_j) = q_{\mathrm{error}}$.


This automata has a $\delta$ that is a total function and accepts and rejects exactly the same set of states that your original automata accepted and rejected.

Edit, January 2019

Commenter @Alex Smart rightly critiques me for neither giving references, nor for explaining why we should care.  So here goes:

The reason we care about the exact definition of determinism vs non-determinism, is that some classes of non-deterministic automata are more powerful than their deterministic cousins, and some classes of non-deterministic automata are not more powerful than their deterministic cousins.  For finite automata and Turing machines the deterministic and non-deterministic variants are of equivalent power.  For pushdown automata there are languages where the distinction is important: There are NPDA that accept the language, and no DPDA accepts the language.  For the linear bounded automata the question is (or was last time I checked) open.  The increase of power of NPDA over DPDA comes from allowing multiple transitions, not from turning the transition function from a total function to a partial function.

Books from the compiler community:

Aho and Ullman, Principles of Compiler Design, 1977: First defines NFA (page 88) with a transition relation, then (p. 90-91):


  We say a finite automaton is deterministic if
  1. It has no transitions on input $\epsilon$.
  2. For each state $s$ and input symbol $a$, there is at most one edge labeled $a$ leaving $s$.


Aho, Sethi, and Ullman, Compilers, principles, tecniques, and tools, 1988 reprint, is similar, it first defines NFA with a transition relation, then (p. 115-116):


  A deterministic finite automata (DFA, for short) is a special case of a non-deterministic finitie automaton in which ... there is at most one edge labeled $a$ leaving $s$.


(Note that in the comments @Alex Smart says, "the dragon specifically mentions that the function is total."  I assume he is talking about the later edition with co-author Lam, which I don't have access to at the moment.)

Appel, Modern Compiler Implementation in Java, 1988 (p. 22):


  In a deterministic finite automaton (DFA), no two edges leaving from the same state are labeled with the same symbol.


Appel then goes on to explain that when using DFA to recognize longest matches we explicitly make use of the missing transitions to decide when to stop (p. 23):


  when a dead state (a nonfinal state with no output transitions) is reached, the variables [which record the longest match we've seen so far] tell what token was matched, and where it ended.


Books from the switching-theory community:

Kohavi, Switching and Finite Automata Theory, 2/e, 1978, p. 611 says:


  Because a state diagram describes a deterministic machine, the next state transition must be determined uniquely by the present state and the presently scanned input symbol.


I would typically interpret uniquely to mean "exactly one", not "no more than one".  (I.e., Kohavi seems to be saying that determinism requires a total function)

Books from the theory-of-computation community:

Here it seems to be more common to define DFAs before NFAs, and require DFAs to have a total transition function, but then define NPDAs before DPDAs, and define "determinism" as being a restriction of the transition relation to having no-more-than-one entry for each state/symbol pair.

This is true of Hopcroft and Ullman, 1979, Lewis and Papadimitriou, 1981, and, especially of Sipser, 2006, who uses the definition of DFA pedagogically to introduce precise formal definitions, and explain their importance and explicitly says (p.36):


  the transition function, $\delta$, specifies exactly one next state for each possible combination of a state and an input symbol.


This seems to follow the historical development.  Deterministic finite automata were introduced in the 40s and 50s.  Non-determinisitc finite automata were introduced in the paper by Rabin and Scott, "Finite automata and their decision problems, IBM J. Rsrch and Dvpt, 3(2):114-125, 1959.  Following earlier authors, Rabin and Scott define deterministic finite automata (which they call ordinary automata) as having a transition function "defined on the Cartesian product $s\times\Sigma$ of all pairs of states and symbols."  (Which I would interpret as meaning a total function).

Interestingly Rabin and Scott, also define non-deterministic finite automata in terms of a total function!  Page 120, Definition 9:


  A nondeterministic (finite) automaton ... is a system where ... $M$ is a function[!] of $S\times\Sigma$ with values in the set of all subsets of $S$.


That is: the transition function being total does not make the system deterministic!

Sipser 2006 follows Rabin and Scott and uses a total transition function from states/symbols to the power set of states for his definitions of non-deterministic finite automata, non-deterministic PDA, and non-deterministic Turing Machines, but skips the topic of deterministic PDA.

Both Hopcroft and Ullman, 1979, and Lewis and Papadimitriou, 1981 use partial functions in their definitions of deterministic PDAs.  They first define NPDAs with a transition relation, and then when they get to PDAs, Lewis and Papadimitriou say (p. 135),


  A pushdown automaton is deterministic, intuitively speaking, if there is at most one transition applicable to each configuration.


While Hopcroft and Ullman say (p. 112):


  The PDA ... is deterministic in the sense that at most one move is possible from any ID.