Assignment 5 Bounding Complexities KEY Print this sheet and fill in your answers. Please staple the sheets together. Turn in at the beginning of class on Friday, September 16. There are links in the examples below that take you to the Desmos website and the Wolfram Math website, where these examples are shown graphically. Multiple functions are plotted in different colors. Use the key on the right of the webpage to determine the color for each function. We have also included the URLs of these links so you can copy/paste them if you are working from a pdf file. If you are working from a pdf file, the blue, underlined hyperlinks don t usually work. You have to copy/paste the URL into your browser. The link names we included are in black font and are underlined, but clicking on them does not take you to the website you have to copy/paste the URL into your browser. Complexity The worst case complexity of an algorithm (the maximum number of basic operations it might perform) is a function of the size of its input. So when comparing the complexity of algorithms, we are comparing functions. If we have two functions,, we can determine their relationship as their input sizes grow by looking at the ratio /. For example, 5, 2, / 5/2. The ratio of the two functions does not depend on the input size. So the algorithm whose complexity is requires 2.5 times more operations than the algorithm for no matter the size of n. Their complexities are within a constant factor of each other, even as n grows toward infinity. (Example URL: https://www.desmos.com/calculator/aui8zxkukn) Another example,,, /. Here function grows faster. The gap between them gets larger and larger as n grows. The gap in the complexities for the two algorithms with these complexities grows logarithmically with the input. As n grows toward infinity, so does the gap, and dwarfs. (Example URL: https://www.desmos.com/calculator/phn1qxhdwx) The relationships between functions we want to identify are: meaning that is an asymptotic upper bound on, within a constant factor. It is read as f of n is order g of n or f is big oh of g of n. meaning that is an asymptotic lower bound on, within a constant factor. It is read as f is big omega of g of n. meaning that is an asymptotically tight bound on, bounding it above and below within a constant factor. It is read as f is big theta of g of n. If and, then. Hence if, then there exist positive constants,, such that for all :
Additionally 1 there are: meaning that is an upper bound on that is not asymptotically tight. It is read as f is little oh of g of n. For example, 2, but 2. Where is analogous to, is analogous to. Hence if, then 0. meaning that is a lower bound on that is not asymptotically tight. It is read as f is little omega of g of n. For example,, but. If you think of as analogous to, then is analogous to. Hence if:, then. Instructions: Fill in the blanks with one of the five symbols (O, Ω, Θ, o, or ω) to indicate the relationship between the functions. 1. If, then = Ω_ 2. If, then = ω_ 3. Since, it is also true that = _O and = Ω _ Instructions: For these next two problems, fill in the first blank with the ratio of these two functions. Next determine what that implies about bounding and fill in the other blank(s) with one of the five symbols listed above. 4. If and, then / = _log 2 n, which means that = ω and = _ Ω 1 Some functions are not asymptotically comparable at all (URL: https://www.desmos.com/calculator/dz1cecgcmr)
5. If / and 75, then / = _1/75. This ratio means that = _Θ_ (Click here to see graphs of the functions and their ratios. URL: https://www.desmos.com/calculator/zsbmddwpda) Facts about exponents: 1/ / and if 0 if 0 The polynomial may start slow, (URL: https://www.desmos.com/calculator/g5geljqgja) but will overtake the log (URL: https://www.desmos.com/calculator/ppb3ddzm6i) eventually. See the approximate solutions (click here, URL: https://www.wolframalpha.com/input/?i=x%5e0.1+%3d+log_2(x) ) for. (try changing the function to. and see what happens this website is Wolfram Math, and you can change the function you want to plot near the top of the webpage) Instructions: For these problems, fill in the first blank with the ratio of these two functions. Next determine what that implies about bounding and fill in the other blanks with one of the five symbols (O, Ω, Θ, o, or ω). 6. If. and., then / = _n 0.1 _, which means that = _o and = _O 7. If. and, then / = _n 0.2 /log 2 n, which means that = ω and = Ω
Facts about exponential functions:, if c and d are constants such that 1, 0 Check out the solutions to 1. 1 (at this link, URL: https://www.wolframalpha.com/input/?i=1.1%5ex+%3d+x%5e2), 1.01 (at this link, URL: https://www.wolframalpha.com/input/?i=1.01%5ex+%3d+x%5e2), and 1.001 (at this link, URL: https://www.wolframalpha.com/input/?i=1.001%5ex+%3d+x%5e2) Instructions: Fill in the blanks with one of the five symbols (O, Ω, Θ, o, or ω) to indicate the relationship between the functions. 8. If 3 and, then = ω and = Ω Instructions: Fill in the first blank with the ratio of these two functions. Next determine what that implies about bounding and fill in the other blanks with one of the five symbols listed above. 9. If 2 and 3, then / = (2/3) n, which means that = _o and = _O
Facts about comparing sums of functions: If, then Essentially, we can ignore all but the largest term If 3 9 4, then / 3 9/ 6/. As, those last two terms approach 0. Check out the graph (URL: https://www.desmos.com/calculator/zqqizfs2sh), and try changing the 9 to 900. See the limit for / (click this link, URL: https://www.wolframalpha.com/input/?i=limit%5b(4+%2b+9+n+%2b+3+n%5e2)%2f(n %5E2),+%7Bn+ %3E+Infinity%7D%5D) Also see the limit for / (click this link, URL: https://www.wolframalpha.com/input/?i=limit%5bn%5e2%2f(4+%2b+9+n+%2b+3+n% 5E2),+%7Bn+ %3E+Infinity%7D%5D). Instructions: For this question, fill in the first blank with the ratio of these two functions. Next determine what that implies about bounding and fill in the other blank with one of the five symbols (O, Ω, Θ, o, or ω). 10. If (see this link, URL: https://www.wolframalpha.com/input/?i=sum+i,+i%3d1+to+n), and, then / = _1/2 + 1/(2n)_, which means that = _Θ_ Facts about logarithm bases: Check out these log functions of different bases and their relationships (URL: https://www.desmos.com/calculator/mnykkwcpvt) Instructions: Fill in the first blank with the ratio of these two functions. Next determine what that implies about bounding and fill in the other blank with one of the five symbols (O, Ω, Θ, o, or ω). 11. If and, then / = _3_, which means that = Θ