Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Compsci algorithms help

(1) show that 0.1n + 10*sqrt(n) is not the same as O(sqrt(n)) using the definition of O only

Consider the obvious algorithm for checking whether a list of integers is sorted: start at the beginning of the list, and scan along until we first find a successive pair of elements that is out of order.

In that case, return false. If no such pair is found by the time we reach the end of the list, return true. Our elementary operation is a comparison between two integers.

(2)

(a) What is the worst case running time of this algorithm on an input list containing n elements? Write all 5-element input lists which contain the numbers 1,2,3,4,5 and yield the worst case.

(b) What is the best case running time of this algorithm on an input list with n elements? How many input lists are there which have size n, all elements being different, and yield the best case?

(c) Suppose that the input list is a random permutation of 1,2,...,n and all such permutations are equally likely. Derive the average-case expected running time. Give both an exact and asymptotic answer.

(3)

A certain algorithm has running time T(n) on input of size n given by T(n) = nblgnc+ 2n−2blg nc+1.

(a) Prove that T(n) is Θ(nlogn).

(b) Prove that T(n)−nlgn is O(n).

(c) Explain why the limit rule could not be used for

(b). Hint: Let L(n) := lgn−blgnc and think about the properties of the function L. For example, how large can it be, and what values does it take when n = 1,2,...?

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question