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
What is cpu????????????????????????????
Paul [167]

Answer:

CPU

Explanation:

CENTRAL

PROCESSING

UNIT

8 0
3 years ago
Read 2 more answers
The following statement calls a function named half, which returns a value that is half
nadezda [96]

Answer:

function half(number) {

     let result = number/2;

     return result;

}

Explanation:

4 0
3 years ago
Jana works in a call center helping people who are having trouble setting up their
olchik [2.2K]

Answer:

Information Support and Services

Explanation:

She works helping people setting up their accounts so she supports with information from her services

4 0
2 years ago
Read 2 more answers
If you are using a sprite for your MakeCode Arcade game, which code block
xeze [42]

Answer:

set mySprite block

Explanation:

BRAINLIEST?

8 0
2 years ago
Read 2 more answers
What is an oxidation state?
vekshin1
Based on the definition which states it is an indicator of oxidation of an atom in a chemical compound. I believe the most viable answer is the charge of an atom's ion.
7 0
3 years ago
Other questions:
  • Suggest two other subtasks that may be performed in a dice game?
    15·2 answers
  • Robert needs to apply formatting from one set of text to multiple other sets of text throughout the document. Which option shoul
    7·1 answer
  • What kind of fragment is near the computer?
    14·1 answer
  • They begin beating it with a hose to find out what it really means. How does the figurative language in this excerpt reveal Coll
    9·2 answers
  • Which access control principle specifies that no unnecessary access to data exists by regulating members so they can perform onl
    11·1 answer
  • ___ is an example of a function prototype.
    12·1 answer
  • Create a function called "strip_r_o" that takes in a STRING and strips all the Rs and Os from the string. Also use a FOR loop in
    7·1 answer
  • The Marketing Department for CSM Tech Publishing is busy producing videos and print materials (stored in PDF format) for distrib
    6·1 answer
  • I found a brand-new charger wire still in its plastic package, but it's six years old and has never been used. Is it safe to use
    9·1 answer
  • Explain different users of computer in briefly?​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!