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.
19. for to nfor to ifor to j next knext jnext i
Compute the actual number of the elementary operation by execution of algorithm.
On each iteration of the inner for-loop execute exactly once whichmultiplication. Thus in total execute 2 operation per iteration of inner for-loop.
Determine the number of iteration of the inner for-loop. k can goes from 1 to j which are j-1+1=j possible values and j varies from 1 to i and i varies from 1 to n.
No of iteration inner loop=
Use the theorem on polynomial order to find the order for the algorithm segments
Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!Get Started