The difference between this and Big O is that Big O has to do with exponential complexity, the same list to loop through potentially having to be looped against for every step in an outer loop, etc. The "find the longest palindrome" example would apply to Big O. In little o the inner loop is just a different thing altogether with its size not bound to the size of the first loop to being with. An example might be one in which we have two lists of words and we want to make a third list that only has words in both the lists, perhaps to give bonus offers to customers (usernames for the words) enrolled in two separate loyalty programs or some such hogwash. Also, you can see the right way and the wrong way to this, right? The wrong way makes for easy to read code but is expensive. You could just have a loop across the first list with a loop inside for the second list creating an a times b level of expensive/complexity. The better thing to do is to sort both lists alphabetically and then increment a position in the second list appropriately as you walk the first list and therein just walk the second list once. Also, Big O measures the most expensive possible circumstance while big Ω the least and big ϴ both, and I thought I'd mention it with everything else here. The upper bounds and the lower bounds are the proper terms for what I am dubbing "most" and "least" respectively.
No comments:
Post a Comment