Time complexity is usually calculated in terms of the number of times certain operations are carried out by an algorithm, e. G. , the number of additions or subtractions, the number of multiplications, the number of comparisons made (if statements). Typically, we count the number of times a certain operation, e. G, a comparison, and give a Big-O estimate. There are three possible cases of interest: Best-case: by sheer, dumb luck, what is the easiest problem we might have to solve? Worst-case: by sheer, bad luck, what is the worst problem we might have to solve?
Average-case: what is the mean complexity over all possible sets of inputs. CASES/209 ? Lecture 4: Best, Worst, and Average Case Complexity 3/1 1 Of these, “best-case” is the easiest and “average-case” is the hardest. “Worst-case” is the most important (why? ) and turns out to be asymptotically similar to average-case. Japan Bangladesh Economic Relationship By Kaisers k=l k-1 -1. Exercise Prove that IQ-I = k (k – 1)+1 Lecture 4: Best, Worst, and Average Case Complexity CASES/209 ? Example: Binary Search Recall the Binary Search algorithm?
The Binary Search Algorithm Find the index of the element x in the ordered list {al < a2 < a3 < an }. 1 Split the list into two sublists al ,a2,… ,aa n/2 +1 , and 2 lfx
get custom paper