- #1
emeraldskye177
- 26
- 0
Homework Statement
Consider the ##xyzzy## algorithm below. This algorithm takes a linear collection (e.g., a list or array) of size ##n## as an argument (i.e., as the input to the algorithm) and produces no return value (i.e., has no output, but might alter the linear collection). Note that the implementation of the ##xyzzy## algorithm requires that you use the unspecified operations ##foo, bar## and ##qux ~-## though you don’t know what these operations do, you can assume they all take the same amount of time to complete. You don’t need to know anything else about them to answer the question below.
If you were attempting to formally analyze the efficiency of this algorithm, which operation (or operations) from the set ##\{foo, bar, qux\}## would be the best choice for the model of computation?
Homework Equations
n/a
3. The Attempt at a Solution
I think the answer is ##qux## because its conditional (while loop) increments ##k## while the loops containing the other operations do not increment their iteration counters; that is, ##j = j * 2## keeps ##j## at ##0## and ##i = i##++ doesn't increment ##i## because the assignment occurs before the ++, so ##i## is perpetually assigned ##0;## rather, ##i =## ++##i## would increment ##i.##
Can someone please verify if I'm approaching this correctly and perhaps lend more insight into what the question's asking? Thanks!