Question
Can I please get help with this question?
Problem 3. How many lines, as a function of n (in 0(.) form), does the following program print? Write a recurrence and solve
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 { function f(n) 2 { 3 if(n>1) 4 5 print.line(still going); # this executes constant time 6 f(n/2); # this executes n/2 ti

Now, the recurrence relation was given by,

T(n)= 1+ T(n/2)+T(n/2) = 2T(n/2)+1

now, by using the masters theorem,

here a=2 and b=2 and k=0

a>bk  -->2>20 (true) so, T(n)=O(nlog ab) =O(nlog 22) =O(n1) =O(n) case1

Therefore T(n)=O(n)

  

Add a comment
Know the answer?
Add Answer to:
Can I please get help with this question? Problem 3. How many lines, as a function...
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
  • Problem 3. How many lines, as a function of n (in O.) form), does the following...

    Problem 3. How many lines, as a function of n (in O.) form), does the following program print? Write a recurrence and solve it. You may assume n is a power of 2. function f(n) { If (n>1) { print.line ("still going");/ f(n/2); f(n/2); }

  • can I get some help I'll try for many hours but still get it wrong. thanks...

    can I get some help I'll try for many hours but still get it wrong. thanks Section 6.3 Step Function: Problem 14 Previous Problem Problem List Next Problem (1 point) Compute the inverse Laplace transform of P(a)= 3 " f(t) = [e"(t-4)-e (2(1-4)]u(t-4) (Notation: write uſt-c) for the Heaviside step function e(t) with step at t = c.) If you don't get this in 2 tries, you can get a hint. Hint: Preview My Answers Submit Answers You have attempted...

  • Can I please get help with this question? Will upvote. thanks. Problem 4. Here's a problem...

    Can I please get help with this question? Will upvote. thanks. Problem 4. Here's a problem that occurs in automatic program analysis. For a set of variables x1, ..., Xn, you are given some equality constraints, of the form "x, = x," and some disequality constraints, of the form “x, #x": Is it possible to satisfy all of them? For instance, the constraints x, = XX, = x3,x; = x, *, * x. cannot be satisfied. Give a polynomial time...

  • Can i please get help with problem 3? please, if possible, answer in a text format....

    Can i please get help with problem 3? please, if possible, answer in a text format. JN/2) f(n/2); f(n/2); f(n/2); Problem 3. Let A[O...n-1) be an array of n distinct integers. A pair (Ali), A[]) is said to be an inversion if these numbers are out of order, i.e., i<j but A[i] > AG). Design a O(n log n) time algorithm for counting the number of inversions.

  • python Hi guys, I really need help with that please Can I get help with this...

    python Hi guys, I really need help with that please Can I get help with this python program? Please write clear Show all the steps please, the outcome and follow the directions. Volume # Purpose: This program computes the volume (in liters) of a six-pack of soda cans and the total volume of a six-pack and a two-liter bottle. Complete the following: # Liters in a 12-ounce can and a two-liter bottle. # Number of cans per pack. # Calculate...

  • Algorithms question: Please help if you can Find how many times the string “CS3130” will be...

    Algorithms question: Please help if you can Find how many times the string “CS3130” will be printed in each of the following code fragments. Show all the details of calculations; your answer must be a function of n. (a) i=0 while i < 2n       print “CS3130”       i = i+2       (b) i=0 while i < n     for j = 0 to n          print “CS3130”     i = i+1 (c) for i = 0 to n    ...

  • can i please get a detailed description of how to do this problem? i have asked...

    can i please get a detailed description of how to do this problem? i have asked this same question multiple times and I still have no cule how to do it. please write on paper (hint: the answers are 331.30 N and 129.71 N Done Expert Q&A PLEASE WRITE ON PAPER NO TYPING the o m His c 10.0 m is from the from the bottom of of his head m the same force Find the one that the forests...

  • Can I get some help with this problem? Can someone show how do this in C?...

    Can I get some help with this problem? Can someone show how do this in C? Thank you for your help. Write a C object-oriented program that reads the coordinates of two points in the plane and shows the distance between them. In order to do that implement the class Point.    Point{       float x;       float y;       Point(): void       set (float x, float y): void       getX( ): float (optional implementation)       getY( ): float (optional...

  • Consider python please for this problem: I did a python program to read the first 20 lines from a...

    Consider python please for this problem: I did a python program to read the first 20 lines from a file and here is the code holder = 20 lines = 3 file = "123456.pssm" _file = ".txt" while 1:         out_file = input("[OUTPUT] - Please enter the name of file: ") + _file         if (not _file):         print("Filename not specified - Please Try Again\n")         continue     break with open(_file, "a") as e:     with open(file, "r") as f:         for num, line in enumerate(f, 1):                        ...

  • Please write neat so I can read and understand the problem. (1 point) In this exercise...

    Please write neat so I can read and understand the problem. (1 point) In this exercise we consider finding the first five coefficients in the series solution of the first order linear initial value problem 3y" - xy + 4y = 0 subject to the initial condition y(0) = 3, y'(0) = 2. Since the equation has an ordinary point at x = 0 and it has a power series solution in the form y= 2" We learned how to...

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
ADVERTISEMENT