# Proving that co-finite languages can be decided in constant time

I am trying to show that given a co-finite language $$A$$, $$A \in \text{TIME}(1)$$.

If $$A$$ is co-finite, $$A$$ is regular, so $$A \in \text{TIME}(n)$$.

I'm not sure how to proceed from here. Any hints?

• Hint: if there are only a constant number of words, say $m$, not in $A$, how many symbols of the input do you need to read to decide if it is in $A$ or not? – dkaeae Nov 27 '18 at 8:58
• What's the complexity of deciding finite languages? – Raphael Nov 27 '18 at 11:47

Your observation that co-finite languages are regular and hence in linear time is absolutely correct. Unfortunately, it's not enough, since there are definitely regular languages that require linear, and not constant, time (e.g., even checking if your input matches $$0^*$$ requires you to look at the whole input, unless $$\Sigma=\{0\}$$).