1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Natali5045456 [20]
3 years ago
5

Give a big-O estimate for the number of operations,

Computers and Technology
1 answer:
Kazeer [188]3 years ago
6 0

Answer:

Explanation:

For the first iteration of i for loop 1 to n, the j for loop will run from 2 to n times. i.e. n-1 times.

For the second iteration of i for loop, the j for loop will run from 3 to n times. i.e. n-2 times.

From the third to the last iteration of i for loop, the j for loop will run n-1 to n times. i.e. 2 times.

From the second to the last iteration of i for loop, the j for loop will run from n to n times. i.e. 1 time.

For the last iteration of i for loop, the j for loop will run 0 times because i+1 >n.

Hence the equation looks like below:

1 + 2 + 3 + ...... + (n-2) + (n-1) = n(n-1)/2

So the number of total iterations is n(n-1)/2.

There are two operations per loop, i.e. Comparison and Multiplication, so the iteration is 2 * n(n-1)/2 = n ^2 - n

So f(n) = n ^ 2 - n

f(n) <= n ^ 2 for n > 1

Hence, The algorithm is O(n^2) with C = 1 and k = 1.

You might be interested in
Concentric circles on a disk platter where data is stored;________
bagirrra123 [75]

Answer:

Tracks

Resilient File System (ReFS)

Explanation:

  1. Concentric circles on a disk platter where data is stored is called Tracks
  2. The new file system developed for Windows Server 2012 is called Resilient File System (ReFS). It allows increased stability for disk storage and improved features for data recovery and error checking
4 0
3 years ago
Find the root using bisection method with initials 1 and 2 for function 0.005(e^(2x))cos(x) in matlab and error 1e-10?
frutty [35]

Answer:

The root is:

c=1.5708

Explanation:

Use this script in Matlab:

-------------------------------------------------------------------------------------

function  [c, err, yc] = bisect (f, a, b, delta)

% f the function introduce as n anonymous function

%       - a y b are the initial and the final value respectively

%       - delta is the tolerance or error.

%           - c is the root

%       - yc = f(c)

%        - err is the stimated error for  c

ya = feval(f, a);

yb = feval(f, b);

if  ya*yb > 0, return, end

max1 = 1 + round((log(b-a) - log(delta)) / log(2));

for  k = 1:max1

c = (a + b) / 2;

yc = feval(f, c);

if  yc == 0

 a = c;

 b = c;

elseif  yb*yc > 0

 b = c;

 yb = yc;

else

 a = c;

 ya = yc;

end

if  b-a < delta, break, end

end

c = (a + b) / 2;

err = abs(b - a);

yc = feval(f, c);

-------------------------------------------------------------------------------------

Enter the function in matlab like this:

f= @(x) 0.005*(exp(2*x)*cos(x))

You should get this result:

f =

 function_handle with value:

   @(x)0.005*(exp(2*x)*cos(x))

Now run the code like this:

[c, err, yc] = bisect (f, 1, 2, 1e-10)

You should get this result:

c =

   1.5708

err =

  5.8208e-11

yc =

 -3.0708e-12

In addition, you can use the plot function to verify your results:

fplot(f,[1,2])

grid on

5 0
3 years ago
Which line in the following program will cause a compiler error? #include using namespace std; int main() { int number =5; if (n
DanielleElmas [232]

Answer:

  1. #include  <iostream>
  2. using namespace std;
  3. int main() {
  4. int number =5;
  5. if (number>=0&& number <=100){
  6.    cout<<"passed.\n";
  7. }
  8. else{
  9.    cout<<"failed.\n";
  10. }
  11. return 0;
  12. }

Explanation:

There where multiple errors in the code given in the questions

Line 1: Missing <iostream>

Line 5: The comparison operator was wrong correction is highlighted

Line 12 Missing closing brace for the main function

All the errors have been fixed and the code above compiles

4 0
2 years ago
What happens if you never confirm your facebook account?
OleMash [197]
Nothing, it will just keep sending you annoying notifications that become more and more frequent, i would just confirm it if i were you
5 0
3 years ago
How do design elements and color work together on a web page?
KiRa [710]

Answer:

The answer I believe is: 2. Both Enhance visual appeal.

Explanation:

4 0
2 years ago
Other questions:
  • What role do you think mobile devices have played in shaping the world?
    13·1 answer
  • Can somebody help me?
    11·1 answer
  • Which option correctly describes a DBMS application? A. software used to manage databases B. software used to organize files and
    7·2 answers
  • What is the main purpose of a graphic organizer?
    10·2 answers
  • In C!!
    11·1 answer
  • 8.10 quiz edhesive A swap is: a variable used to find the smallest value in an array an algorithm used to find a value in an arr
    12·1 answer
  • takes the perspective that a program describes what the solution to a problem is, not how that problem is solved. Select one: a.
    5·1 answer
  • Does any of yall play rob lox?
    5·2 answers
  • An end-user license agreement protects _____.
    11·1 answer
  • Define a function Output Value() that takes two integer parameters and outputs the sum of all negative integers starting with th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!