For each of the algorithm segments in 6—19, assume that n is a positive integer. (a) Compute the actual number of elementary operations (additions, subtractions, multiplications, divisions, and comparisons) that are performed when the algorithm segment is executed. For simplicity, however, count only comparisons that occur within if then statements; ignore those implied by for-next loops. (b) Use the theorem on polynomial orders to find an order for the algorithm segment.
9. for to nfor to 2n next jnext i
The computation of actual number of elementary operations performed.
The given algorithm segment is,
s := 0
for I := 1 to n
for j := 1 to 2n
s := s + i. j
Theorem on polynomial orders:
Let be real numbers and let
An order for the given algorithm segment.
Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!Get Started