Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

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

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) .

Alice wants to throw a party and is deciding whom to call. She has n people to choose from, and she has made up a list of which pairs of these people know each other. She wants to pick as many people as possible, subject to two constraints: at the party, each person should have at least five other people whom they know and five other people whom they don’t know. Give an efficient algorithm that takes as input the list of n people and the list of pairs who know each other and outputs the best choice of party invitees. Give the running time in terms of n

Is there a faster way to compute the nth Fibonacci number than by fib2 (page 4)? One idea involves matrices.

We start by writing the equations F1=F1 and F2=F0+F1 in matrix notation:


role="math" localid="1659767046297" (F1F2)=(0111).(F0F1).

Similarly,

F2F3=(0111).(F1F2)=(0111)2.(F0F1)

And in general

(FnFn+1)=(0111)n.(F0F1)

So, in order to compute Fn, it suffices to raise this 2×2 matrix, call it X, to the nth power.

a. Show that two 2×2matrices can be multiplied using 4additions and 8multiplications.

But how many matrix multiplications does it take to compute Xn?

b. Show that O(logn) matrix multiplications suffice for computing Xn. (Hint: Think about computing X8.)

Thus, the number of arithmetic operations needed by our matrix-based algorithm, call it fib3, is just O(logn), as compared to O(n)for fib2. Have we broken another exponential barrier? The catch is that our new algorithm involves multiplication, not just addition; and multiplications of large numbers are slower than additions. We have already seen that, when the complexity of arithmetic operations is taken into account, the running time offib2becomes O(n).

c. Show that all intermediate results of fib3 are O(n) bits long.


d. Let M(n)be the running time of an algorithm for multiplying n-bit numbers, and assume that M(n)=O(n2) (the school method for multiplication, recalled in Chapter 1, achieves this). Prove that the running time of fib3 is O(M(n)logn).


e. Can you prove that the running time of fib3 is O(M(n))? Assume M(n)=Θ(na)for some 1a2. (Hint: The lengths of the numbers being multiplied get doubled with every squaring.)


In conclusion, whether fib3 is faster than fib2 depends on whether we can multiply n-bit integers faster thanO(n2) . Do you think this is possible? (The answer is in Chapter 2.) Finally, there is a formula for the Fibonacci numbers:

role="math" localid="1659768125292" Fn=15(1+52)n15(152)n.

So, it would appear that we only need to raise a couple of numbers to the nth power in order to computeFn . The problem is that these numbers are irrational, and computing them to sufficient accuracy is nontrivial. In fact, our matrix method fib3 can be seen as a roundabout way of raising these irrational numbers to the nth power. If you know your linear algebra, you should see why. (Hint: What are the eigenvalues of the matrix X?)

The kSPANNING TREE problem is the following.Input: An undirected graph G=(V,E) Output: A spanning tree of G in which each node has degree k, if such a tree exists.Show that for any k2:

  1. k SPANNING TREE is a search problem.
  2. k SPANNING TREE is NP-complete. (Hint: Start with k=2 and consider the relation between this problem and RUDRATA PATH.)

Consider the following game. A “dealer” produces a sequence s1···sn of “cards,” face up, where each card si has a value vi. Then two players take turns picking a card from the sequence, but can only pick the first or the last card of the (remaining) sequence. The goal is to collect cards of largest total value. (For example, you can think of the cards as bills of different denominations.) Assume n is even. (a) Show a sequence of cards such that it is not optimal for the first player to start by picking up the available card of larger value. That is, the natural greedy strategy is suboptimal. (b) Give an O(n2) algorithm to compute an optimal strategy for the first player. Given the initial sequence, your algorithm should precompute in O(n2) time some information, and then the first player should be able to make each move optimally in O(1) time by looking up the precomputed information.

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