Previous | Next --- Slide 34 of 86
Back to Lecture Thumbnails
kayvonf

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.

Do I have the right idea here?

mlakshmi

How about i % 8 == 0 as an if condition?