Should the question mark be in the middle of a sentence?

The goal is to answer questions of the form "is vertex v connected to w?" in constant time.

Should the question mark be there? A related question is how this sentence might be made better?


Just FWIW ..

"A related question is how this sentence might be made better?"

I hate or love/hate writing involving computer science and related topics.

For example, a HUGE problem is that ("no matter how often I tell them not to!") programmers won't accept that the plural form of a Class in software is always the same word with no damned S on the end. Just like fish. It's absurd to add an "s" on the end of class names or variable names, because of the obvious technical confusion that could create.

Similarly there are huge annoying ugly issues with CamelCasePhrases, endBraces(), and the like.

Anyway, I'd write this:

The goal is to answer questions of the form: "Is
vertex v connected to w?" in constant time.

Sometimes just adding a few colons, ellipses, etc., can help clarify and slow-down the sentence.

For example,

http://answers.unity3d.com/questions/263302/vertices-array-in-mesh-vertices.html

Note that someone was saying: "It is an absolutely true statement
that Unity shares vertices where it can. There is no situation where
this is not true." ... that statement, is utterly incorrect.

Notice the drunk writer got away with a double sentyence, quoted, and following punctuation! But it's reasonably clear: because: of the excessive use of ( * ) stars ( * ) ellipses ( * ) colons and ( * ) dashes.

I feel with computer science discussions, it's really hard to avoid such "concrete-poetry -like" sentences, loaded with comma or dash interludes, star or dash lists, and colon or ellipsis lnks.

When discussing comp sci it's almost impossible not to "nest" a lot, because the topic is very much like that. You inevitably have to describe some complex concept, and then, comment on that in a complex way. (Exactly as in the example at hand from the OP.)

Indeed regarding nesting:

Often the "final solution" is to become much more long winded, and get in to using, well, variables in writing.

For the example you gave:

Consider questions like: "Is vertex v connected to
vertex w?"  Let's refer to such questions as VWQ
questions. Our goal is to answer VWQ questions in
constant time.

Note that say R. Dawkins does this where necessary (and does it very well).

(For vertices specifically, I suggest ultimately giving-up and drawing diagrams :) http://answers.unity3d.com/questions/266972/detecting-mesh-orientation.html )