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
balu736 [363]
3 years ago
10

Consider the following recursive method: public int someFun(int n) { if (n <= 0) return 2; else return someFun(n-1) * someFun

(n-1); } (a) When the program calls someFun(5), how many times will someFun(3) be called? (b) What does this method calculate when the input parameter n is a non-negative integer?
Computers and Technology
1 answer:
Stella [2.4K]3 years ago
3 0

Answer:

(a) someFunc(3) will be called 4 times.

(b) For non negative number n someFunc method calculates 2^2^n.

Explanation:

When you call someFunc(5) it will call someFunc(4) two time.

So now we have two someFunc(4) now each someFunc(4) will call someFunc(3) two times.Hence the call to someFun(3) is 4 times.

someFunc(n) calculates someFunc(n-1) two times and calculates it's product.

someFunc(n) = someFunc(n-1)^2..........(1)

someFunc(n-1)=someFunc(n-2)^2..........(2)

substituting the value form eq2 to eq 1.

someFunc(n)=someFunc(n-2)^2^2

       .

       .

       .

       .

= someFunc(n-n)^2^n.

=2^2^n

2 raised to the power 2 raised to the power n.

You might be interested in
The default case is required in the switch selection statement.
babunello [35]

Answer: False

Explanation:

 The given statement is false, as it is not compulsory that the default case is require in switch selection statement. If the default case are not properly specified in the statement then, there will be no execution occur in the switch selection statement.

It is sometimes good to have default case in switch selection statement, but it is not mandatory. The default case only executed when the correct case is present and none of the case matches in the given statement.

5 0
3 years ago
What is an allocation unit?
sdas [7]
It is a unit of disk space allocation for files and directories. Hope this helps :) 
5 0
3 years ago
Which of the following is not a group of energy sources?
Dimas [21]

Answer:

nonrenewable

Explanation:

Brainliest please

4 0
3 years ago
Read 2 more answers
Python 3.4
Dmitrij [34]
I = 0
while( i < ( n * 2 ) ):
   s += '*'
   i += 1
8 0
3 years ago
What is the first step to apply the line and page breaks options to groups of paragraphs in a Word document?
bezimeni [28]

Answer:

accessing the Paragraph dialog box

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Monica needs a printer to use at home. She wants fine-quality prints at an affordable cost. Which printer will help her achieve
    9·1 answer
  • A c++ member function that uses, but does not change, the value of a member variable is called
    13·1 answer
  • Technician A says that the reserve rating of a battery is the amount of steady current that a fully charged battery can supply f
    6·1 answer
  • Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print o
    6·1 answer
  • Bob works at a cafe where he earns $11 an hr. which of the following graphs describes the amount of money that bob earns after x
    9·2 answers
  • To connect a peripheral device to a computer to exchange data, find the appropriate ________ for the device.
    7·1 answer
  • (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)Ex:Davy's auto shop servicesOil chan
    9·1 answer
  • I was killed <br><br> යඞ <br><br> what do i do
    10·1 answer
  • A data center needs to ensure that data is not lost at the system level in the event of a blackout. Servers must stay operable f
    6·1 answer
  • Choose the term that describes each step of the cycle.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!