What is the Big-O Notation of the following code snippet?
1 2 3 4 5 6 |
|
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
As the input size n grows the number of steps taken by the while loop grows logarithmically.
We can see this by observing the number of times the while loop is executed for different n values for the input list
product_prices
.n = len(product_prices)