Question
Give a big- $O$ estimate for the number of operations (where an operation is an addition or a multiplication) used in this segment of an algorithm.$$\begin{array}{c}{t :=0} \\ {\text { for } i :=1 \text { to } 3} \\ {\quad \text { for } j :=1 \text { to } 4} \\ {t :=t+i j}\end{array}$$
Step 1
The base operation is the operation that is performed most frequently. In this case, the base operation is $t := t + ij$, which includes one multiplication and one addition. Show more…
Show all steps
Your feedback will help us improve your experience
James Chok and 52 other Calculus 2 / BC educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Give a big-O estimate for the number of operations (where an operation is an addition or a multiplication) used in this segment of an algorithm: t := 1 for i = n to n^2 t := t + 2it Show all steps.
Give a big- $O$ estimate for the number of operations, where an operation is an addition or a multiplication, used in this segment of an algorithm (ignoring comparisons used to test the conditions in the while loop). $$ \begin{array}{c}{i :=1} \\ {t :=0} \\ {\text { while } i \leq n} \\ {\quad t :=t+i} \\ {i :=2 i}\end{array} $$
Algorithms
Complexity of Algorithms
Give a big- $O$ estimate for the number of operations, where an operation is a comparison or a multiplication, used in this segment of an algorithm (ignoring comparisons used to test the conditions in the for loops, where $a_{1}, a_{2}, \ldots, a_{n}$ are positive real numbers). $$ \begin{array}{c}{m :=0} \\ {\text { for } i :=1 \text { to } n} \\ {\quad \text { for } j :=i+1 \text { to } n} \\ {m :=\max \left(a_{i} a_{j}, m\right)}\end{array} $$
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD