Please note that the content of this book primarily consists of articles available from Wikipedia or other free sources online. In computer programs, an important form of control flow is the loop.At a first glance, one might think that the second variant of the algorithm is slower than the first, since it changes the value of some of the entries twice. But the number of extra changes is only n, and the numb ...Full description
Please note that the content of this book primarily consists of articles available from Wikipedia or other free sources online. In computer programs, an important form of control flow is the loop.At a first glance, one might think that the second variant of the algorithm is slower than the first, since it changes the value of some of the entries twice. But the number of extra changes is only n, and the number of comparisons that don't have to be done is n2; clearly, for large enough values of n, the second algorithm will be faster no matter the relative cost of comparisons and assignments, since we do less work in the innermost loop.Assume that do_something_A takes 100 ¿s to run, and do_something_B takes 1 ¿s.