Ask Computer Engineering Expert

Q1. Little-Oh

Recall the definition of Big-Oh:

∃c ∈ R+, ∃n0 ∈ R+, ∀n ∈ N, n ≥ n0 ⇒ g(n) ≤ cf(n)

Here is one variation of this definition.

Definition 1 (little-oh). Let f, g : N → R≥0. We say that g is little-oh of f, and write g ∈ o(f), when:

∀c ∈ R+, ∃n0 ∈ R+, ∀n ∈ N, n ≥ n0 ⇒ g(n) ≤ cf(n)

This is a stronger property than Big-Oh, in the sense that if g ∈ o(f), then g ∈ O(f). While g ∈ O(f) says (colloquially) that "it is possible to scale up f so that it eventually dominates g," g ∈ o(f) says that "no matter how you scale f (up or down), it will always eventually dominate g." Or, in terms of rates of growth, g ∈ O(f) means that g grows at most as quickly as f, while g ∈ o(f) means that g grows strictly slower than f.

Prove the following statements about little-oh, using only the definitions of little-oh and Big-Oh. You may not use any external properties of Big-Oh in this question.

(a) Prove that for all positive real numbers a and b, if a < b then na ∈ o(nb).

(b) Prove that for all functions f, g : N → R+, if g ∈ o(f) then f ∉ O(g).

Note: we've restricted the range of f and g to exclude 0.

Q2. A tricky nested loop

Our goal for this question is to analyse the running time of the following function:

1 def nested(n):

2 """Assume n is an integer that is greater than 1."""

3 b = 1

4 while b <= n:   # Loop 1

5 i = 1

6 while i < b:       # Loop 2

7 print(i)

8 i = i * 3

9 b = b + 1

(a) First, prove that for all functions f, g : N → R+ and b ∈ R+, if all three of the following conditions are true:

(i) g(n) ∈ O(f(n))

(ii) f(n) and g(n) are eventually ≥ b [Correction: this used to say ≥ 1]

(iii) b > 1

then logb(g(n)) ∈ O(logbf(n)).

You may not use any external properties about Big-Oh; we're looking for you to prove this statement using the definition of Big-Oh.

(b) Find an exact expression for the total number of iterations of the inner loop of nested, in terms of the function's input n. Your expression may contain summation notation (e.g., i=1ni); you do not need to simplify it here. Make sure to use the floor and/or ceiling functions to ensure that you're counting with natural numbers.

(c) Determine, with proof, a good upper bound (Big-Oh only) on the running time of nested, in terms of the value of its input n. Note that by \good" we mean that it should be possible to prove the matching Omega lower bound, even though we are not requiring it here.

You can use the statement you proved in part (a), and your solution to part (b), and the following external facts:

∀x ∈ R, x ≤ ⌈x⌉ < x + 1                                                    (Fact 1)

n! ∈ Θ (en ln n - n + ½ ln n)                                               (Fact 2)

the exponent of e in Fact 2 is eventually ≥ 1                        (Fact 3)

Q3. Algorithm analysis

Consider the following function, which takes in a list of integers.

1 def my_sum(L):

2 x = 0

3 y = 1

4 n = len(L)

5 i = 0

6 while x + y < n:

7 if L[i] % 2 == 0:

8 y = y + 1

9 else:

10 x = x + y

11 i = i + 1

Let WC(n) and BC(n) represent the worst-case and best-case runtime functions of my sum, respectively.

(a) Prove that WC(n) ∈ O(n), where n is the length of the input list to my sum.

(b) Prove that WC(n) ∈ Ω(n), where n is the length of the input list to my sum.

(c) Prove that BC(n)  ∉ Θ(n), where n is the length of the input list to my sum. You can use the definition of Theta that says g ∈ Θ (f) if and only if g ∈ O(f) Λ g ∈ Ω(f).

Attachment:- Assignment Files.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92242390

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 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