subject

For each of the following six program fragments: a. give an analysis of the running time (big-oh will do).b. implement the code in the language of your choice, and give the running timefor several values of n. c. compare your analysis with the actual running times.(1) sum = 0; for( i = 0; i < n; ++i )++sum; (2) sum = 0; for( i = 0; i < n; ++i )for( j = 0; j < n; ++j )++sum; (3) sum = 0; for( i = 0; i < n; ++i )for( j = 0; j < n * n; ++j )++sum; (4) sum = 0; for( i = 0; i < n; ++i )for( j = 0; j < i; ++j )++sum; (5) sum = 0; for( i = 0; i < n; ++i )for( j = 0; j < i * i; ++j )for( k = 0; k < j; ++k )++sum; (6) sum = 0; for( i = 1; i < n; ++i )for( j = 1; j < i * i; ++j )if( j % i == 0 )for( k = 0; k < j; ++k )++sum;

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 20:50, solo4360
What does operator overloading allow you to do?
Answers: 2
image
Computers and Technology, 22.06.2019 07:00, candiceforever123
Idon understand these and need some ! ?
Answers: 2
image
Computers and Technology, 23.06.2019 13:10, BrianKeokot4534
What is domain name system (dns)? allows dynamic ip address allocation so users do not have to have a preconfigured ip address to use the network converts ip addresses into domains, or identifying labels that use a variety of recognizable naming conventions the efficient coexistence of telephone, video, and data communication within a single network, offering convenience and flexibility not possible with separate infrastructures the integration of communication channels into a single service
Answers: 2
image
Computers and Technology, 25.06.2019 04:30, greenbyron88
You can fit more raw files on a memory card than the jpeg files? truefalse
Answers: 1
You know the right answer?
For each of the following six program fragments: a. give an analysis of the running time (big-oh wil...

Questions in other subjects: