Question: 0.1. In each of the following situations, indicate whether f=O(g),orf=Ω(g),or both (in which case f=(g))

Short Answer

Expert verified

Answer

Theindicationofthefollowingsituationsareasfollows,a)Thefunctionsarefn=n-100andgn=n-200,whichmatchesfn=Θg(n)andcanbewrittenasn-100n-200.b)Thefunctionsaref(n)1/2andgn=n2/3,whichmatchesfn=Θg(n)andcanbewrittenas.c)Thefunctionsarefn=100n+lognandgn=100n+logn2,whichmatchesfn=Θg(n)andcanbewrittenasn2/3=O(n2/3).d)Thefunctionsarefn=nlognand,whichmatchesfn=Θg(n)andcanbewrittenlogn=Θn+logn2.e)Thefunctionsarefn=log2nandgn=log3n,whichmatchesogn=Θn+logn2andcanbewrittenasogn=Θn+logn2.f)Thefunctionsarefn=log10nandg(n)=nlog2n,whichmatchesandcanbewrittenasn1.01=nlog2ng)Thefunctionsaref(n)=n1.01andg(n)=nlog2n,,whichmatchesn1.01=nlog2n,

h)Thefunctionsaref(n)=n2/lognandgn=nlogn2,whichmatchf(n)=Ωg(n)andcanbewrittenasn2logn=Ωnlogn2.i)Thefunctionsarefn=lognlognandg(n)=nlogn,whichmatchf(n)=Ωg(n)andcanbewrittenaslognlogn=Ωn/lognj)Thefunctionsarefn=n1.01andgn=nlogn,whichmatchf(n)=Ωg(n)andcanbewrittenasn1.01=nlog2n.K)Thefunctionsaref(n)=nandgn=logn3,whichmatchf(n)=Ωg(n)andcanbewrittenasn=Ω(logn)3.I)Thefunctionsaref(n)=n12andgn=5log2n,whichmatchf(n)=Ωg(n)andcanbewrittenasn12=O5(log2m).m)Thefunctionsarefn=n2nandgn=3n,whichmatch(n)=Og(n)andcanbewrittenasn2n=3n.n)Thefunctionsarefn=2nandgn=2n+1,whichmatch(n)=Og(n)andcanbewrittenas2n=2n+1.o)Thefunctionsarefn=n!andgn=2n,whichmatchfn=Ωg(n)andcanbewrittenasn!=Ω((2)n).p)Thefunctionsarefn=lognlognandgn=2log2n2,whichmatchfn=Og(n)andcanbewrittenasognlogn=O2log2n2.q)Thefunctionsarefn=i=1nikandgn=nk+1,whichmatchfn=Θg(n)andcanbewrittenasi=1n=Θnk+1.

Step by step solution

01

Step 1: Introduction of the concept

An event's indicator function is a random variable that takes the value 1 when the event occurs and 0 when the event does not.

02

Step 2: Solution (a)

The given functions are:

fn=n-100andgn=n-200

Because f=O(g)and g=O(f)orf=Ω(g)are , the function mentioned above corresponds to the case.

  1. f=O(g)denotes when comparing the computing speed of two functions, f(n) and g(n); it is said that f(n) is no faster than g(n).
  2. f=Ω(g) denotes when comparing the computing speed of two functions, f(n) and g(n); it is said that g(n) is no faster than f(n).

Thus, is the case that corresponds to the above function, and the function can be expressed as n-100=Θ(n-200).

03

Step 3: Solution (b)

The given functions are:

.f(n)1/2andgn=n2/3

Because while collating the powers (n)1/2<n2/3, the above-mentioned function corresponds to the case fn=Θg(n).

  1. When comparing two functions f(n) and g(n), the big-O notation fn=Og(n)states that g(n) has a faster computational speed than f(n).
  2. According to the principles for simplifying functions,(n)1/2 is dominatedby n2/3; hence, g(n) is better than f(n).

Thus, fn=Θg(n)is the case that matches the preceding function, and the function can be represented as (n)1/2=O(n2/3).

04

Step 4: Solution (c)

The given functions are:

fn=100n+lognandgn=100n+logn2

Because f=O(g)and localid="1658215662597" g=O(f)orf=Ω(g) are O(n), the above-mentioned function corresponds to the casefn=Θg(n).

  1. f=O(g)denotes when comparing thecomputing speed of two functions, f(n) and g(n), it is said that f(n) is no faster than g(n).
  2. denotes when comparing the computing speed of two functions, f(n) and g(n), it is said that g(n) is no faster than f(n).
  3. Any polynomial dominates any logarithmaccording to the criteria for simplifying functions. It means that 100n dominates log n in f(n)and n dominates in g(n).

Thusfn=Θg(n), is the case that corresponds to the above function, and the function can be expressed as100n+logn⊙g(n)=100n+logn2.

05

Step 5: Solution(d)

The given functions are:

fn=nlognandg(n)=10nln10n.

Because f=O(g)and g=O(f)orf=Ω(g) , the above-mentioned function corresponds to the casefn=Θg(n).

  1. denotes when comparing the computing speed of two functions, f(n) and g(n), it is said that f(n) is no faster than g(n).
  2. denoteswhen comparing the computing speed of two functions, f(n) and g(n), it is said that g(n) is no faster than f(n).
  3. Any polynomial dominates any logarithm according to the criteria for simplifying functions.

Thus, fn=Θg(n)is the case that corresponds to the above function, and the function can be expressed aslocalid="1658217762370" nlogn=⊙10log10n.

06

Step 6: Solution (e) 

The given functions are:

fn=log2nandgn=log3n.

Because f=O(g)and g=O(f)orf=Ω(g), the above-mentioned function corresponds to the casefn=Θg(n).

  1. denotes when comparing the computing speed of two functions, f(n) and g(n), it is said that f(n) is no faster than g(n).
  2. denoteswhen comparing the computing speed of two functions, f(n) and g(n), it is said that g(n) is no faster than f(n).
  3. Any polynomial dominates any logarithmaccording to the criteria for simplifying functions.

Thus,fn=Θg(n)is the case that corresponds to the above function, and the function can be expressed aslog2n=(log3n) .

07

Step 7: Solution (f)

The given functions are:

f=O(g)andg=O(f)orf=Ω(g).

Because and are, the above-mentioned function corresponds to the casefn=Θg(n).

  1. f=O(g)denotes when comparing the computing speed of two functions, f(n) and g(n), it is said that f(n) is no faster than g(n).
  2. f=Ω(g) denotes when comparing the computing speed of two functions, f(n) and g(n), it is said that g(n) is no faster than f(n).

Thus,fn=Θg(n) is the case that corresponds to the above function, and the function can be expressed as 10logn=(log(n2)).

08

Step 8: Solution (g)

The given functions are:

f(n)=n1.01andg(n)=nlog2n.

The above-mentioned function corresponds to the casef(n)=Ωg(n).

  1. The values of the functions f(n) and g(n)should be compared if they are divided by n, but the comparison will take longer.
  2. However, according to the simplification rules, the function with the highest power value wins; hence,f(n) is better than g (n).
  3. indicates that when comparing two functions,f(n) and g(n),it is said that f(n) is not dominated by g(n).

Thus, f(n)=Ωg(n)is the case that corresponds to the above function, and the function can be expressed asn1.01=nlog2n .

09

Step 9: Solution (h)

The given functions are:

f(n)=n2/lognandgn=nlogn2 .

The above-mentioned function corresponds to the case f(n)=Ωg(n).

  1. The values of the functions f(n) and g(n)should be compared if they are divided by , but the comparison by the functions n and there are divisible.
  2. However, according to the simplification rules, the function with the highest power value wins; hence,f(n) is better than g (n).
  3. indicates when comparing two functions,f(n) and g(n), it is said that f(n) is not dominated by g(n).

Thus, f(n)=Ωg(n)is the case that corresponds to the above function, and the function can be expressed asn2logn=Ωn(logn)2.

10

Step 10: Solution (i)

The given functions are:

and fn=n1.01andgn=log10.

The above-mentioned function corresponds to the casef(n)=Ωg(n).

  1. The values of the functions f(n) and g(n)should be compared if they are divided by n, but the comparison will take longer.
  2. However, according to the simplification rules, the function with the highest power value wins; hence,f(n) is better than g (n).
  3. f=Ω(g) indicates when comparing two functions f(n) and g(n), it is said that f(n) is not dominated by g(n).

Thus, f(n)=Ωg(n)is the case that corresponds to the above function, and the function can be expressed as n1.01=nlog2n..

11

Step 11: Solution (j)

The given functions are:

n=lognlognandg(n)=nlogn .

The above-mentioned function corresponds to the case.role="math" localid="1658221596761" f(n)=nloglogn

  1. The function f(n) can be expressed as f(n)=Ωg(n), and the function with the highest power value wins; therefore,f(n) beats g(n).
  2. indicates that when comparing two functions,f(n) and g(n), it is said that f(n) is not dominated by g(n).

Thus,f(n)=Ωg(n) is the case that corresponds to the above function, and the function can be expressed as(logn)logn=Ωnlogn.

12

Step 12: Solution (k)

The given functions are:

and .f(n)=nandgn=logn3

The above-mentioned function corresponds to the casef(n)=Ωg(n).

  1. The values of the functions f(n) and g(n)should be compared if they are divided by n, but the comparison will take longer.
  2. However, according to the simplification rules, the function with the highest power value wins; hence,f(n) is better than g (n).
  3. indicates that when comparing two functions,f(n) and g(n), it is said that f(n) is not dominated by g(n).

Thus, f(n)=Ωg(n)is the case that corresponds to the above function, and the function can be expressed asn=Ω(logn)3..

13

Step 13: Solution (l)

The given functions are:

.fn=lognlognandg(n)=nlogn

The above-mentioned function corresponds to the casef(n)=Ωg(n).

  1. Because while collating the powers , the function g(n) is written as .
  2. When comparing two functions, f(n) and g(n), the big-O notation states that g(n) has a faster computational speed than f(n).
  3. According to the principles for simplifying functions, is dominatedby ; hence,g(n) is better than f(n).

Thusf(n)=Ωg(n), is the case that matches the preceding function, and the function can be represented aslognlogn=Ωn/(logn) .

14

Solution (m) 

The given functions are:

fn=n2nandgn=3nfn=n2nandgn=3n.

The above-mentioned function corresponds to the caseF(n)=Og(n).

  1. Here, the comparing powers.
  2. When comparing two functions, f(n) and g(n), the big-O notation states that g(n) has a faster computational speed than f(n).
  3. According to the principles for simplifying functions, is dominated by ; hence,g(n) is better than f(n).

Thus, F(n)=Og(n)is the case that matches the preceding function, and the function can be represented as n2n=3n.

15

Step 15: Solution (n)

The given functions are:

fn=2nandgn=2n+1.

Because and are , the above-mentioned function corresponds to the caseF(n)=Og(n).

  1. denotes when comparing the computing speed of two functions, f(n) and g(n), it is said thatf(n) is no faster than g(n).
  2. denotes when comparing the computing speed of two functions, f(n) and g(n), it is said that g(n) is no faster than f(n).

Thus, localid="1658226767960" F(n)=Og(n)is the case that corresponds to the above function, and the function can be expressed as2n=2n+1..

16

Step 16: Solution (o)

The given functions are:

afn=n!andgn=2n

The above-mentioned function is in the case of fn=Ωg(n).The value of is and is known.

  1. denotes when comparing the computing speed of two functions, f(n) and g(n), it is said thatf(n) is no faster than g(n).

Thus, fn=Ωg(n)is the case that corresponds to the above function, and the function can be expressed asn!=Ω((2)n)..

17

Step 17: Solution (p)

The given functions are:

fn=lognlognandgn=2log2n2.

The above-mentioned function corresponds to the casefn=Og(n).

  1. Thefunction f(n)can be expressed as , and the function g(n)can be expressed as .
  2. Here, the function with the power value succeeds. Thus,f(n) is a higher level than g(n)
  3. When comparing two functions, f(n) and g(n), the big-O notation states that f(n) has a faster computational speed than g(n).

Thus,fn=Og(n) is the case that matches the preceding function, and the function can be represented as(ogn)logn=O2(log2n)2

18

Step 18: Solution Explanation (q)

The given functions are:

fn=i=1nikandgn=nk+1

Because f=O(g)and g=O(f)orf=Ω(g), the above-mentioned function corresponds to the casefn=Θg(n).

  1. denotes when comparing thecomputing speed of two functions, f(n) and g(n), it is said that g(n) is higher-level than g(n).
  2. denotes when comparing the computing speed of two functions, f(n) and g(n), it is said that g(n) is higher-level than f(n).

Thus, fn=Θg(n)is the case that corresponds to the above function, and the function can be expressed asi=1n=Θ(nk+1)..

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

A vertex cover of a graph G=(V,E)is a subset of vertices SVthat includes at least one endpoint of every edge in E. Give a linear-time algorithm for the following task.

Input: An undirected tree T=(V,E).

Output: The size of the smallest vertex cover of T. For instance, in the following tree, possible vertex covers include{A,B,C,D,E,F,G}and{A,C,D,F}but not{C,E,F}.The smallest vertex cover has size 3: {B,E,G}.

How long does the recursive multiplication algorithm (page 25) take to multiply an n -bit number by an m -bit number? Justify your answer.

Mean and median. One of the most basic tasks in statistics is to summarize a set of observations x1,x2,,xnR by a single number. Two popular choices for this summary statistic are:

• The median, which we’ll callμ1

• The mean, which we’ll callμ2

(a) Show that the median is the value of μthat minimizes the function

i|xi-μ|

You can assume for simplicity that is odd. (Hint: Show that for any , the function decreases if you move either slightly to the left or slightly to the right.)

(b) Show that the mean is the value of μ that minimizes the function

i(xi-μ)2

One way to do this is by calculus. Another method is to prove that for any μR,

i(xi-μ)2=i(xi-μ2)2+n(μ-μ2)2

Notice how the function for μ2 penalizes points that are far from much more heavily than the function for μ1 . Thus μ2 tries much harder to be close to all the observations. This might sound like a good thing at some level, but it is statistically undesirable because just a few outliers can severely throw off the estimate of μ2 . It is therefore sometimes said that μ1 is a more robust estimator than μ2 . Worse than either of them, however, is μ , the value of μthat minimizes the function

maxi|xi-μ|

(c) Show that μ can be computed in O(n) time (assuming the numbers are xismall enough that basic arithmetic operations on them take unit time).

The tramp steamer problem. You are the owner of a steamship that can apply between a group of port cities V . You make money at each port: a visit to city i earns you a profit of pi dollars. Meanwhile, the transportation cost from port i to port j is cij>0 .You want to find a cyclic route in which the ratio of profit to cost is maximized.

To this end, consider a directed graph G=(V,E) whose nodes are ports, and which has edges between each pair of ports. For any cycle C in this graph, the profit-to-cost ratio is

role="math" localid="1658920675878" r(c)=i,jicPiji,jicCij

Let r' be the maximum ratio achievable by a simple cycle. One way to determine r' is by binary search: by first guessing some ratio r , and then testing whether it is too large or too small. Consider any positive r>0 . Give each edge (i,j) a weight of wij=rcij-pj .

  1. Show that if there is a cycle of negative weight, then .
  2. Show that if all cycles in the graph have strictly positive weight, then r<r*.
  3. Give an efficient algorithm that takes as input a desired accuracy >0 and returns a simple cycle c for which r(C)3r*- Justify the correctness of your algorithm and analyze its running time in terms of |V|, and R=max(i,j)iE(PJCIJ) .

Here’s a problem that occurs in automatic program analysis. For a set of variablesx1,......,xn, you are given some equality constraints, of the form “ xi=xj” and some disequality constraints, of the form “ xixj.” Is it possible to satisfy all of them?

For instance, the constraints.

x1=x2,x2=x3,x3=x4,x1x4

cannot be satisfied. Give an efficient algorithm that takes as input m constraints over n variables and decides whether the constraints can be satisfied.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free