Question

Let T(n) represent the total execution time of a loop for which the loop test is...

Let T(n) represent the total execution time of a loop for which the loop test is true n times (i.e., the loop body will execute n times). For each possible value of T(n) listed below, give a tight upper bound for the time cost (in terms of O(…)) of one execution of the loop body (denote this by L(n)) that makes the statement true. Answer each part separately. Each answer should be of the form L(n) = O(…)

a. T(n) = O(n2 )

b. T(n) = O(n)

c. T(n) = O (n lg n)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Since the loop will be true n times

So, the net complexity will become n times too

So,

A)

L(n)=O(n^3)

B)

L(n)=O(n^2)

C)

L(n)=O(n^2*log(n))

Add a comment
Know the answer?
Add Answer to:
Let T(n) represent the total execution time of a loop for which the loop test is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Let f(n) = 5n^2. Prove that f(n) = O(n^3). Let f(n) = 7n^2. Prove that f(n)...

    Let f(n) = 5n^2. Prove that f(n) = O(n^3). Let f(n) = 7n^2. Prove that f(n) = Ω(n). Let f(n) = 3n. Prove that f(n) =ꙍ (√n). Let f(n) = 3n+2. Prove that f(n) = Θ (n). Let k > 0 and c > 0 be any positive constants. Prove that (n + k)c = O(nc). Prove that lg(n!) = O(n lg n). Let g(n) = log10(n). Prove that g(n) = Θ(lg n). (hint: ???? ? = ???? ?)???? ?...

  • Q6) let T(n) be a running time function defined recursively as 0, n=0 n=1 3T(n -...

    Q6) let T(n) be a running time function defined recursively as 0, n=0 n=1 3T(n - 1)- 2T(n - 2), n> 1 a) Find a non-recursive formula for T(n) b) Prove by induction that your answer in part (a) is correct. c) Find a tight bound for T(n).

  • Let P(t) represent the number of people who, at time t, are infected with a certain disease. Let ...

    Let P(t) represent the number of people who, at time t, are infected with a certain disease. Let N denote the total number of people in the population. Assume that the spread of the disease can be modeled by the initial value problem: dP/dt = k(N − P)P, P(0) = P0. At time t = 0, when 100,000 member of a population of 500,000 are known to be infected, medical authorities intervene with medical treatment. As a consequence of this...

  • Let G (V, E) be a directed graph with n vertices and m edges. It is known that in dfsTrace of G t...

    Let G (V, E) be a directed graph with n vertices and m edges. It is known that in dfsTrace of G the function dfs is called n times, once for each vertex It is also seen that dfs contains a loop whose body gets executed while visiting v once for each vertex w adjacent to v; that is the body gets executed once for each edge (v, w). In the worst case there are n adjacent vertices. What do...

  • Let T(n) be the running time of function select_even. Find the equation of T(n) and find...

    Let T(n) be the running time of function select_even. Find the equation of T(n) and find the complexity of T(n) using big-O notation. def select_even(L): output = [] for x in L: if x%2==0: output.append(x) return output

  • Let T(n) be the running time of function foo. Find the equation of T(n) and find...

    Let T(n) be the running time of function foo. Find the equation of T(n) and find the complexity of T(n) using big-O notation. def foo(L): s = 0 for x in L: j = len(L) while j > 1: j = j / 2 s = s + x print(s) return s

  • A rectangular loop of wire with dimensions and w is released from rest at time t...

    A rectangular loop of wire with dimensions and w is released from rest at time t = 0 from a region with zero magnetic field into a region with uniform magnetic field Bo pointing into the page. At t=0, the upper edge of the loop is in the zero field region and the lower edge is in the uniform field region as shown in the figure below. The loop has mass m and the acceleration due to gravity is g...

  • 6. Let T(1..n] be a sorted array of distinct integers, some of which may be negative....

    6. Let T(1..n] be a sorted array of distinct integers, some of which may be negative. Give an algorithm that can find an index i such that 1 <i<n and T[i] = i, provided such an index exists. Your algorithm should take a time in O(lg n) in the worst case. Answers must be proven (or at least well justified)

  • Question2 0/5 pts If exact running time of an algorithm is T(n)-5n3+ n2 + 3n -5...

    Question2 0/5 pts If exact running time of an algorithm is T(n)-5n3+ n2 + 3n -5 where n is the input size, then which of the following is true? T(n)- O(n) RCOECEQuestion 3 0/5 pts Which of the following is the correct ranking of the functions listed below: logn. n2 n2n, 2. 1500. nlogn, 5 Question 4 5/5 pts to search

  • Analyze and prove the running time of the recursive formula T(n) = n2 + 2T(n/2). (hint-...

    Analyze and prove the running time of the recursive formula T(n) = n2 + 2T(n/2). (hint- first prove that it is O(n2 logn). Next see if you could improve your answer. We used the recursion tree method to analyze the running time of MergeSort. Use this method to analyze each one of the following recursive formulas, and obtain its solution. Assume T(n) = 1 when n ≤ 1. Analyze and prove the running time of the recursive formula T(n) =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT