Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Below is the definition of the useless function:

1: function useless(n)

2: if n = 1 then

3: return 1

4: else

5: return useless(random(1, n))

6: end if

7: endfunction

where random(1, n) returns a uniformly distributed random integer in the range 1 . . . n.

Assuming an initial call to the function useless(m).

Point: The function will return 1 or will run infinitely.

Q1. How to prove it formally?

Point: Call to random function on line 5 will occurred whenever m is not equal to 1 and it will be infinite until m equals to 1.

Q2. So, how exactly we can calculate the expected no. of calls to random function?

Point: For best case scenario of useless function [useless(1)], calls for random function will be 0.

Q3. But what about the worst case scenario(useless(n) where n not equal to 1), how many times random function will be called?

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93100821
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Computer Engineering

The task is to implement closest pair algorithm along with

The task is to implement closest pair algorithm. Along with the implementation in c++, I want two additional things. Thing 1. Test the correctness of your algorithm in the following way: Generate 100 random points in the ...

Part 1 if false change the incorrect parts to make them

Part 1, If false, change the incorrect parts to make them true. DO NOT NEGATE THE FALSE SENTENCES. 1. According to the weak-form efficient market hypothesis, investors can take advantage of historical information. 2. The ...

Why regulated industries should be required to follow

Why regulated industries should be required to follow security standards. Provide 2 examples of industries that would fall under this category.

Explain the differences between working in the web based

Explain the differences between working in the web based version of Outlook in Office 365 to the desktop application version of Outlook.

Suppose kelvin has seven controls listed as the top tier of

Suppose Kelvin has seven controls listed as the top tier of project initiatives. At his next meeting with Charlie, he provides a rank-ordered list of these controls with projected losses over the next 10 years for each i ...

Create a class named horse that contains data fields for

Create a class named Horse that contains data fields for the name, color, and birth year. Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field that hol ...

Rock paper scissors please make sure it compiles and

Rock, Paper, Scissors (Please make sure it compiles and include output in answer.) You will implement a rock-paper-scissors game. The player enters 1 for Rock, 2 for Paper, or 3 for Scissors. The computer randomly select ...

Command to mail only the process id of running java program

Command to mail only the process ID of running Java program test to the email address (single line Unix)

One of the basic motivations behind the minimum spanning

One of the basic motivations behind the Minimum Spanning Tree Problem is the goal of designing a spanning network for a set of nodes with minimum total cost. Here we explore another type of objective: designing a spannin ...

On microsoft word what would be the advantage of using the

On Microsoft word, what would be the advantage of using the dialog box over setting various tabs directly on the ruler line? In what types of typing tasks would you find using the ruler line helpful?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As