Question: Describe a simple piece of code with a single if statement that could yield worst-case performance when run on eight different pieces of data.
bigtimecore
In response to the question - a set of operations on a vector of size 8 with a conditional statement if x[i-1] might be very inefficient, because each step relies on a previous step in order to execute order to execute.
Question: Describe a simple piece of code with a single
if
statement that could yield worst-case performance when run on eight different pieces of data.In response to the question - a set of operations on a vector of size 8 with a conditional statement
if x[i-1]
might be very inefficient, because each step relies on a previous step in order to execute order to execute.Do I have the right idea here?
How about i % 8 == 0 as an if condition?