Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data structures class 2. (12 p.) Describe the order of magnitude (order of growth) of each of the following code segments using (single term) Big-

Data structures class
2. (12 p.) Describe the order of magnitude (order of growth) of each of the following code segments using
(single term) Big- notation. Assume that all the variables have been previously declared. For a bonus point
count the exact number of operations for each code segment (represent it as a function of n).
(a)
sum = 0;
for (i = 1; i <= n; i++)
sum++;
(b)
sum = 0;
for (i = 1; i <= n; i++)
sum++;
for (j = n; j > 0; j--)
sum++;
(c)
count = 0;
value = n;
while (value > 1) {
value = value / 2;
count++;
}
(d)
sum = 0;
for (i = 1; i < n; i++)
for (j = n; j >= 0; j--)
sum++;
(e)
sum = 0;
for (i = 1; i <= 10; i++)
for (j = 1; j <= n; j++)
sum++;
(f)
count = 0;
value = n;
value = n * ( n + 3) * (n + 5) ;

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

6. Be able to choose and prepare a training site.

Answered: 1 week ago