Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make sure you tell me the BIG-O Consider a representation for integers of arbitr

ID: 3793083 • Letter: M

Question

Make sure you tell me the BIG-O

Consider a representation for integers of arbitrary length that uses a vector of integers to store each digit as a separate element. Each element in the vector is between 0 and 9 (inclusive) and together they represent a larger integer, with the least significant digit first. So, the vector: [83 90 1] would represent the number 10, 938. There are no leading zeros in the numbers. Write a function that takes two such victors and returns a new vector (in the same format) storing the product of the two inputs. You may assume as a precondition that the input victors do not contain elements that are not single, positive digits. You should also enforce this as a post condition on your output. Your solution must allow integers of arbitrary length without overflow. (For example, do not convert any vector to a single integer, since this doesn't allow arbitrary length.) do this like you would do multiplication by hand, digit-by-digit. What is the running time of your function in Big-O notation if both input victors have size n?

Explanation / Answer

Now we have a way to characterize the running time of binary search in all cases. We can say that the running time of binary search is always O(lg n)O(lgn). We can make a stronger statement about the worst-case running time: it's Theta(lg n)(lgn). But for a blanket statement that covers all cases, the strongest statement we can make is that binary search runs in O(lg n)O(lgn) time.

If you go back to the definition of big- notation, you'll notice that it looks a lot like big-O notation, except that big- notation bounds the running from both above and below, rather than just from above. If we say that a running time is Theta(f(n))(f(n)) in a particular situation, then it's also O(f(n))O(f(n))O, left parenthesis, f, left parenthesis, n, right parenthesis, right parenthesis. For example, we can say that because the worst-case running time of binary search is Theta(lg n)(lgn), it's also O(lg n)O(lgn). The converse is not necessarily true: as we've seen, we can say that binary search always runs in O(lg n)O(lgn) time but not that it always runs in Theta(lg n)(lgn) time.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote