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
vladimir2022 [97]
3 years ago
8

Algorithmic Complexity: what is the asymptotic complexity (Big-O) of each code section? Identify the critical section of each.\

Line 1: for (int i=0; i<532; i++) { f(n) = O( ) Line 2: for (int j=1; j
Computers and Technology
1 answer:
AleksandrR [38]3 years ago
4 0

Answer:

Check the explanation

Explanation:

1) f(n) = O( 1 ), since the loops runs a constant number of times independent of any input size

there is no critical section in the code, as a critical section is some part of code which is shared by multiple threads or even processes to modify any shared variable.This code does not contain any variable which can be shared.

2) f(n) = O( log n! ), the outer loop runs for n times, and the inner loop runs log k times when i = k,ie the total number of print will be – log 1 + log2 +log3 +log4+…...+ log n = log (1 . 2 . 3 . 4 . ……. . n ) =log n!

there is no critical section in the code, as a critical section is some part of code which is shared by multiple threads or even processes to modify any shared variable.This code does not contain any variable which can be shared.

Note : Log (m *n) = Log m + Log n : this is property of logarithm

3) f(n) = O( n^2 ), since both outer and inner loop runs n times hence , the total iterations of print statement will be : n +n+n+…+n

for n times, this makes the complexity – n * n = n2

there is no critical section in the code, as a critical section is some part of code which is shared by multiple threads or even processes to modify any shared variable.This code does not contain any variable which can be shared.

You might be interested in
Classify the given items as belonging to the public domain or protected by copyright law.
max2010maxim [7]

Anything protected by the copyright law has a legal concept that grants artists or authors control over their creations. On the other hand, anything in the public domain is not protected by intellectual property laws and the public owns these works.

A book published in 1758 can be classified as belonging to the public domain. According to U.S laws, works or creations published in the U.S before 1924 might be deemed expired.  

As a bloggers, when you hit the publish button, any work created is protected by copyright and the material inside is yours.

A music record from the 1960s - protected by copyright law

An infographic made by the federal government - public domain

A photograph taken in 1980 - protected by copyright law

3 0
3 years ago
Read 2 more answers
Because health and safety are important in all workplaces, not just hazardous ones, what working conditions must ALL employers p
antiseptic1488 [7]
A since fire extinguishers are legally enforced 
5 0
4 years ago
Read 2 more answers
If person A creates an image with a creative common license. Person B then uses the image on his website. Who own the image and
Rudik [331]
Person A, of course. This person is the original maker of the image therefore that person has the rights to that image, person B does not automatically become the owner just by using it on his website. So the answer is person A.
3 0
3 years ago
Why doesn't brainly give me 15 questions a day
Lilit [14]
I’m not sure how to answer that
8 0
3 years ago
Read 2 more answers
Suppose that outFileis an ofstreamvariable and output is to be stored in the file outputData.out. Which of the following stateme
BlackZzzverrR [31]

Answer:

Option b outFile.open("outputData.out");

Explanation:

In C++, there are several classes given to handle output and input of characters to or from files. They are:

  • ofstream that write on files
  • ifstream that read from files

We can use an object of ofstream to hold the contents that we wish to output to an external file. The general syntax is as follows:

           ofstream_obj.open(file_name)

This will create a file with a specific file name and it possesses all the contents from the obstream_obj.

5 0
3 years ago
Other questions:
  • How does the discussion of “Luddites,” “Marx,” and “John Maynard Keynes” in paragraph 21 contribute to the development of the id
    7·1 answer
  • What does the Sort feature do with a database
    13·1 answer
  • The picture that graphically represents the items you use in windows is called a/an
    5·1 answer
  • g Q 2 Suppose I need a data structure having the following characteristics: a) must be very space efficient, and b) I have a goo
    6·1 answer
  • In science class, Patricia is giving a presentation on the different types of flowers in her community. As part of her presentat
    5·1 answer
  • The blue section of the following Venn diagram could represent which of the following Boolean statements?
    14·1 answer
  • I re-made the human version of Daddy Dearest from Friday Night Funkin
    14·2 answers
  • Answer if you know Javascript, html, css, python, and Ruby.
    12·1 answer
  • Office 365 ProPlus can be deployed to your enterprise. When doing so, which tool enables you to choose the language, hardware ar
    5·1 answer
  • Prior to the 1996 NEC, ____ receptacles and cords were permitted. However, now it is mandatory that a separate equipment groundi
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!