Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. For each of the following four program fragments, give an analysis of the run

ID: 3541698 • Letter: 6

Question

6. For each of the following four program fragments, give an analysis of
the running time. Give this time in Big-O notation using function
with the least order of magnitude. Basically don't say the complexity
is O(N9) if it is also O(N2)


(a) Sum = 0;
       for i = 1 to N do
            Sum = Sum +i;


(b) Sum = 0;
        for i = 1 to N do
             for j = 1 to N do
                  for k = 1 to N do
                       Sum = Sum + 1;


(c) Sum = 0;
          for i = 1 to N2 do
                for j = 1 to N do
                  Sum = Sum + 1;

Explanation / Answer

a) O(N)


b) O(N^3)


c) O(N * N2)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote