Computers and Technology

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;

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:30, TheBurntToast
What is the digital revolution and how did it change society? what are the benefits of digital media?
Answers: 1
image
Computers and Technology, 22.06.2019 23:50, Emptypockets451
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form. you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used. hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
image
Computers and Technology, 23.06.2019 13:30, carolelai08
Stops: using the information learned in this course, explain three things you will not do when driving. a. b. c. explain why you will not do these things when driving. starts: using the information learned in this course, explain three things you will do when driving. a. b. c. explain why you will do these particular things when driving. explain one thing you will stop doing as a passenger. explain one thing you will start doing as a passenger.
Answers: 3
image
Computers and Technology, 23.06.2019 15:30, taapeters
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
Do you know the correct answer?
For each of the following six program fragments: a. give an analysis of the running time (big-oh wil...

Questions in other subjects: