Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For each of the following three program fragments, give an analysis of the running time. First, give the total number of times of each statement

For each of the following three program fragments, give an analysis
of the running time. First, give the total number of times of each
statement being executed. Then give the summed/total time in Big-O
notation. Note that you must give the most accurate bigO notation.
For example, if the bigO notation time complexity is O(N2), don't
write O(N9).
(a) i =1;
while i = N do
i =2\times i;
(b) Sum =0;
for i =1 to N3 do
for j =1 to N do
Sum = Sum +1;
(c) Sum =0;
for i =1 to N do
for j =1 to i
2 do
Sum = Sum +1;
(d) x =100;
y =0;
for i =1 to N step 2\times i do
x = x + i;
for j =1 to sqrt(N) do
if x >y/j :
y = y + i/j;
else
y = y -1;
(e) x =0;
for i =1 to N do
y =1;
for j =1 to i do
y = y * j;
x = x + y;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

Analyse the process of new product of development.

Answered: 1 week ago

Question

Define Trade Mark.

Answered: 1 week ago