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
Irina-Kira [14]
3 years ago
5

Give a pseudo-code description of the O(n)-time algorithm for computing the power function p(x,n).Also draw the trace of computi

ng p(3,3)using this algorithm?
Computers and Technology
1 answer:
laila [671]3 years ago
6 0

Answer:

p(x,n)

1. if(n==0)    [if power is 0]

2.    then result =1.

3.else

4. {    result=1.

5.      for i=1 to n.

6.          {  result = result * x. }  [each time we multiply x once]

7.       return result.

8.  }

Let's count p(3,3)

3\neq0, so come to else part.

i=1: result = result *3 = 3

i=2: result = result *3 = 9

i=2: result = result *3 = 27

Explanation:

here the for loop at step 4 takes O(n) time and other steps take constant time. So overall time complexity = O(n)

You might be interested in
1. Why is photographing lightning a difficult process?
bulgar [2K]
<span>1. Why is photographing lightning a difficult process?
</span>Some reasons which come to my mind for saying this are: 1) You get only one chance for the particular situation - it is not like portrait photography where you can go back in the studio if the photos didn't come out well; 2) lightning varies so much in brightness, intensity and location that guessing the proper exposure requires a lot of experience, as well as luck; 3) you are always at some risk when photographing worthwhile lightning; and 4) lightning is a point (line) source, and demands the most of the optical quality of your camera 
<span>
2. What piece of equipment is helpful in capturing lightning photographs?
</span><span><span>SLR camera with B-shutter speed (preferably SLR; you might try using your digital camera, if it has B mode, but this is much more difficult)</span><span>lenses ranging from 28mm to 135mm at minimum. Fixed-focal lenses are preferred over zoomlenses. Aperture ranges should be f/2.8 - f/22.</span><span>sturdy tripod (metal or plastic doesn't make any difference whatsoever at all in safety - if lightning is so close by, you are in trouble anyway)</span><span>cable release, which can be locked</span><span>Slow-speed film: 100 or 200 ISO
</span></span><span>
3. Why is it important to mentally prepare for photographing lightning?
</span><span>When photographing lightning, it’s important to realize that the conditions you are shooting in are unpredictable and dangerous, and there will always be an element of chance and luck involved. So you should prepare yourself.
</span><span>
4. What time of day should you try to photograph lightning?
</span>Nighttime lightning photography is the easiest <span>type
</span><span>
5. Why is composition important in lightning photographs?
It boosts or adds drama to your picture. </span>
6 0
3 years ago
Read 2 more answers
What are paragraphs separated by
Lemur [1.5K]

Paragraphs are usually separated by blank space.

Hope this is what you were looking for :)

6 0
3 years ago
Why Embedded operating systems are also known as real-time operating systems (RTOS)?
kati45 [8]

Answer:

A real-time operating system is an operating system designed to support real-time applications that, usually without buffer delays, process data as it comes in. A real-time system is a time-bound system that has fixed, well defined time constraints.

6 0
3 years ago
An incident response plan should be created be for a software system is released for use.
Nat2105 [25]
The answer is choice “a. True”.
8 0
2 years ago
A(n) ____________ specifies a variable's name and data type.
Alla [95]
I think that would be a function
4 0
3 years ago
Read 2 more answers
Other questions:
  • Questions 6 - 9 Refer to the following code: public class WhatsIt { private int[] values; private double average; public WhatsIt
    7·1 answer
  • Why are many otherwise safety-conscious people victims of Internet crime?
    13·1 answer
  • Write a program that requests a state abbreviation as input and displays the justices appointed from that state. The justices sh
    6·1 answer
  • To quit Word, click the Restore button on the right side of the title bar. <br> True <br> False
    6·1 answer
  • Which email client feature allows you to store the names and information of people you contact frequently?
    5·1 answer
  • Which guideline should you use when downloading software from the Internet?
    15·1 answer
  • Which steps will create a new blank word document
    9·1 answer
  • URGENT!!! Steve wants to change shooting and exposure settings while on his photo shoot. Which camera part will allow him to do
    12·2 answers
  • If a triathlon is a sport combining three events, what do you think would be the word for a sport combining five events?
    7·1 answer
  • Match each with the correct answer.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!