We've seen that asymptotic notations O-, Q-, and O-notation are a tool for focusing on the general shape of a function as opposed to its finer-grained details. We've seen some details that are clearly...


We've seen that asymptotic notations<br>O-, Q-, and O-notation<br>are a tool for focusing on the general shape of a function as opposed to its finer-grained details. We've seen some details that are clearly<br>too fine-grained to be considered, such as constant factors and lower-order terms (e.g., 8n in the function n2 + 8n), while others are fundamental and shouldn't be ignored.<br>One thing we've not yet considered, but that will show up in many places in this course, is the effect of having multiple variables in a function. While we quite often use the variable n when the variable<br>represents the size of a problem, not all problems' sizes can be described with one variable, which leaves us with the interesting question of what happens to additional variables in asymptotic notations.<br>Let's consider that problem by thinking about a few subtly different scenarios.<br>1. Suppose that we create a std::vector with n elements, each of which is a std::vector with m integers. Suppose, too, that we know for sure that m is always [n/2] (i.e., the floor of one-half of n). What<br>is an asymptotic notation that best describes the time required to set all of the integers to zero?<br>2. Suppose that we create a std::vector with n elements, each of which is a std::vector with m integers. Assume that both n and m are positive integers, but there is otherwise no limitation on how they<br>relate to one another. What is an asymptotic notation that best describes the time required to set all of the integers to zero?<br>3. Suppose that we create a std::vector with n elements, each of which is a std::vector with m integers. Assume that both n and m are positive integers, but there is otherwise no limitation on how they<br>relate to one another. What is an asymptotic notation that best describes the time required to set only some of the integers - namely, all of the integers in the first sub-vector, then only the first integer<br>in all the other sub-vectors<br>- to zero?<br>In each case, make sure to briefly explain your reasoning. None of them requires more than a couple of sentences, but simply stating an asymptotic notation is not enough here; you need to tell us why.<br>

Extracted text: We've seen that asymptotic notations O-, Q-, and O-notation are a tool for focusing on the general shape of a function as opposed to its finer-grained details. We've seen some details that are clearly too fine-grained to be considered, such as constant factors and lower-order terms (e.g., 8n in the function n2 + 8n), while others are fundamental and shouldn't be ignored. One thing we've not yet considered, but that will show up in many places in this course, is the effect of having multiple variables in a function. While we quite often use the variable n when the variable represents the size of a problem, not all problems' sizes can be described with one variable, which leaves us with the interesting question of what happens to additional variables in asymptotic notations. Let's consider that problem by thinking about a few subtly different scenarios. 1. Suppose that we create a std::vector with n elements, each of which is a std::vector with m integers. Suppose, too, that we know for sure that m is always [n/2] (i.e., the floor of one-half of n). What is an asymptotic notation that best describes the time required to set all of the integers to zero? 2. Suppose that we create a std::vector with n elements, each of which is a std::vector with m integers. Assume that both n and m are positive integers, but there is otherwise no limitation on how they relate to one another. What is an asymptotic notation that best describes the time required to set all of the integers to zero? 3. Suppose that we create a std::vector with n elements, each of which is a std::vector with m integers. Assume that both n and m are positive integers, but there is otherwise no limitation on how they relate to one another. What is an asymptotic notation that best describes the time required to set only some of the integers - namely, all of the integers in the first sub-vector, then only the first integer in all the other sub-vectors - to zero? In each case, make sure to briefly explain your reasoning. None of them requires more than a couple of sentences, but simply stating an asymptotic notation is not enough here; you need to tell us why.
Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here