Analyze algorithms worst-case running time


Homework: Algorithm Design & Analysis

Instructions

According to our suggested 16 week "Course Schedule," you should complete. Answer each of the following questions in a clear and comprehensive manner. You can find the homework marking criteria at the end of this document.

Task

• Show that if f(n) is O(h(n)) and g(n) is O(i(n)), then f(n) + g(n) is O(h(n) + i(n)).

• Show that 3(n + 1)7 + 2n log n is O(n7). Hint: Try applying the rules of Theorem 1.7. You will have to use the insert equations to answer this question.

• Give an O(n)-time algorithm for computing the depth of each node of a tree T, where n is the number of nodes of T. Assume the existence of methods setDepth (v,d) and getDepth(v) that run in O(1) time.

• What does the following algorithm do? Analyze its worst-case running time and express it using "Big-Oh" notation.

Algorithm Foo (a,n):
Input: two integers, a and n
Output: ?
k ß 0
b ß 1
while k < n do
k ßk + 1
b ß b *a
return b

• (i) Describe (in pseudo-code) a findAll Elements (k) method of an AVL tree T. It should run in O(logn + s) time where n is the size of T and s is the number of elements returned (i.e., the number of nodes in T whose key is k).

(ii) Analyze the running time of your algorithm.

Format your homework according to the give formatting requirements:

• The answer must be using Times New Roman font (size 12), double spaced, and typed, with one-inch margins on all sides.

• The response also includes a cover page containing the student's name, the title of the homework, the course title, and the date. The cover page is not included in the required page length.

• Also include a reference page. The references and Citations should follow APA format. The reference page is not included in the required page length.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Analyze algorithms worst-case running time
Reference No:- TGS03195085

Now Priced at $30 (50% Discount)

Recommended (93%)

Rated (4.5/5)