Question

In: Computer Science

6. Let t be a positive integer. Show that 1? + 2? + ⋯ + (?...

6. Let t be a positive integer. Show that 1? + 2? + ⋯ + (? − 1)? + ?? is ?(??+1).

7. Arrange the functions ?10, 10?, ? log ? , (log ?)3, ?5 + ?3 + ?2, and ?! in a list so that each function is big-O of the next function.

8. Give a big-O estimate for the function ?(?)=(?3 +?2log?)(log?+1)+(5log?+10)(?3 +1). For the function g in your estimate f(n) is O(g(n)), use a simple function g of smallest order.

9. Prove that 2x4 + 4x2 + 1 is (x4).

10. Show that 10x3 + 4x + 7 is (x3) by directly finding the constants k, C1, and C2 in the definition “f(x) is (g(x)) if and only if there are positive constants k, C1, and C2 such that C1|g(x)|  |f(x)|  C2|g(x)| whenever x  k”.

SECTION 3.3 Complexity of Algorithms

11. Give a big-O estimate for the number of additions used in this segment of an algorithm. s := 0 for i := 1 to n for j := 1 to n s := s + i + j

12. Give a big-O estimate for the number of operations, where an operation is an addition or multiplication, used in this segment of an algorithm (ignoring comparisons used to test the conditions in the while loop). i := 1 s := 0 while i  n 2 s := s + i i := 2i

13. Given a real number x and a positive integer k, determine the number of multiplications used to find ?2? starting with x and successively squaring (to find x2, x4, x8, and so on). Is this a more efficient way to find ?2? than by multiplying x by itself the appropriate number of times?

14. Determine the least number of comparisons, or best-case performance,

a) required to find the maximum of a sequence of n integers, using Algorithm 1 of Section 3.1.

b) used to locate an element in a list of n terms with a linear search.

15. What is the effect of the time required to solve a problem when you double the size of the input from n to 2n, assuming that the number of milliseconds the algorithm uses to solve the problem with input size n is each of these functions?

a) n3

b) 2n

Solutions

Expert Solution

6.

1t + 2t + 3t + 4t + 5t + 6t + 7t + .... + (n-1)t + nt ; t > 0;

= (1 + 2 + 3 + 4 +5 + 6 + 7 + ...... + (n-1) + n )t ;

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

= (n2 + n)t / 2;

= O(n2t )

7. It is saying each function is big O of next function i.e to arrange in ascending order;

After arranging: (logx)3 < 10x < xlogx < x5 + x3 + x2 < x10 < x!

= (logx)3 = O(10x) = O(xlogx) = O(x5 + x3 + x2) = O(x10) = O(x!)

8.

  ?(?)=(?3 +?2log?)(log?+1)+(5log?+10)(?3 +1)

= (n3 + n2logn)(logn + 1) + (5logn + 10)(n3 + 1)

= n3logn + n3 + n2(logn)2 + n2logn + 5n3logn + 5logn + 10n3 + 10

= n3 (6logn + 11) + n2 ((logn)2 + (logn)) + 5logn + 10

=  n3 (6logn + 11) (ignoring the lower order term)

= O(n3logn)

g(n) = n3logn

9. 2x4 + 4x2 + 1 = (x4) //( not visible in the question, taking )

big Omega function gives the lower bound of a function; i.e 0 <= c*g(n) <= f(n) ; for n <= n0, c =a constant

f(n) = 2x4 + 4x2 + 1 > g(n) = x4 ;

let x = 0;

2*(0) + 4 * (0) + 1 > (0)

1 > 0

in f(n) , 2x4 and 4x2 always give a positive number, so 2x4 + 4x2 is always greater than x4

so 2x4 + 4x2 + 1 = (x4)

10 10x3 + 4x + 7 = (x3)

Theta notation states; there lies two constants c1 , c2 for which c1 g(x) <= f(x) <= c2 g(x) , for all x > k;

c1x3 <= 10x3 + 4x + 7 <= c2x3

to find c1, take the coefficient of the largest term and subtract all the negative coefficient terms from it;

but here no negative terms, so simply take the coefficient of x3 i . 10

c1 = 10;

to find c2 = add all the coefficients i.e 10 + 4 + 7 = 21;

c2 = 21;

10x3 < 10x3 + 4x + 7 < 21x3

when x = 0 : values = 0 , 7 , 0 ( 0 < 7 > 0)

when x =1 : values = 10 , 21 , 21 ( 10 < 21 <=21)  

so k = 1

<c1,c2,k> = <10,21,1>

11. Inner for loop will run n times and outer for loop will run n times;

so total n * n = n2 time it will run;

so complexity = O(n2)


Related Solutions

Let t be a positive integer. Prove that, if there exists a Steiner triple system of...
Let t be a positive integer. Prove that, if there exists a Steiner triple system of index 1 having v varieties, then there exists a Steiner triple system having v^t varieties
Let n be a positive integer. Let S(n) = n sigma j=1 ((1/3j − 2) −...
Let n be a positive integer. Let S(n) = n sigma j=1 ((1/3j − 2) − (1/3j + 1)). a) Compute the value of S(1), S(2), S(3), and S(4). b) Make a conjecture that gives a closed form (i.e., not a summation) formula for the value of S(n). c) Use induction to prove your conjecture is correct.
Let K = { s+t * 2^(1/2), such that s, t are Rational}. Show that K...
Let K = { s+t * 2^(1/2), such that s, t are Rational}. Show that K is a Field
For each positive integer, n, let P({n}) =(1/2^n) . Consider the events A = {n :...
For each positive integer, n, let P({n}) =(1/2^n) . Consider the events A = {n : 1 ≤ n ≤ 10}, B = {n : 1 ≤ n ≤ 20}, and C = {n : 11 ≤ n ≤ 20}. Find (a) P(A), (b) P(B), (c) P(A ∪ B), (d) P(A ∩ B), (e) P(C), and (f) P(B′). Hint: Use the formula for the sum of a geometric series
Let L = {0 r | r = s 2 , s a positive integer}. Give...
Let L = {0 r | r = s 2 , s a positive integer}. Give the simplest proof you can that L is not regular using the pumping lemma.
8.Let a and b be integers and d a positive integer. (a) Prove that if d...
8.Let a and b be integers and d a positive integer. (a) Prove that if d divides a and d divides b, then d divides both a + b and a − b. (b) Is the converse of the above true? If so, prove it. If not, give a specific example of a, b, d showing that the converse is false. 9. Let a, b, c, m, n be integers. Prove that if a divides each of b and c,...
Let x be a fixed positive integer. Is it possible to have a graph G with...
Let x be a fixed positive integer. Is it possible to have a graph G with 4x + 1 vertices such that G has a vertex of degree d for all d = 1, 2, ..., 4x + 1? Justify your answer. (Note: The graph G does not need to be simple.)
Let n be a positive integer. Prove that if n is composite, then n has a...
Let n be a positive integer. Prove that if n is composite, then n has a prime factor less than or equal to sqrt(n) . (Hint: first show that n has a factor less than or equal to sqrt(n) )
Let n be a positive integer. Prove that two numbers n2+3n+6 and n2+2n+7 cannot be prime...
Let n be a positive integer. Prove that two numbers n2+3n+6 and n2+2n+7 cannot be prime at the same time.
(a) Let n = 2k be an even integer. Show that x = rk is an...
(a) Let n = 2k be an even integer. Show that x = rk is an element of order 2 which commutes with every element of Dn. (b) Let n = 2k be an even integer. Show that x = rk is the unique non-identity element which commutes with every element of Dn. (c) If n is an odd integer, show that the identity is the only element of Dn which commutes with every element of Dn.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT