Hey,
In the q5 it states about the algo: "This process continues until either the stack or the queue is empty."
But in the pseduocode it has for the looping iteration:
"WHILE (Q and S are not empty) DO" (bold is my own emphasis.)
So either should we refer to the pseudo code that states a requirement of both stack AND queue being empty, or should we refer to the writing which states an "either or" clause (in this case a logically exclusive or?).
Since for question 5c, it is asking us for worse case O complexity for a program that terminates, but it also states the "input" is number of elements S + number of elements Q.
Then either:
option 1? The S and Q are uneven they would only terminate with the written instructions and not with the "WHILE AND" pseduocode instructions. So based on the written instructions, the termination complexity does not really entirely depend on the "input" N=S+Q, but more like the "smaller" of the two arrays. So the input is "S", or "Q" whichever seems shorter.
option 2? Or if S and Q are an even amount and terminate both instructions seem valid... Then the "input" does not really rely on N, since N=S+Q. But more like the sum of the lengths of the arrays divided by two, or (S+Q)/2 or "S" or "Q" since S=Q.
- So which interpretation of the code should we follow? Written? Psudocode?
- Given we need to treat N inputs to do the O complexity analysis, per the instruction are we allowed to substitute N size for simply S or Q length?







