# Comp 3051 algorithm design and analysis

## Assignment 2

### Instructions

According to our suggested 16 week “Course Schedule,” you should complete and submit Assignment 2 by the Sunday at the end of Week 6. This assignment is worth 10% of your final grade. To receive full marks, answer each of the following questions in a clear and comprehensive manner. You can find the assignment marking criteria at the end of this document.

### Questions

1.  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)).

[2 marks]

2. 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. [2 marks]

3. 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.  [2 marks]

4. What does the following algorithm do? Analyze its worst-case running time and express it using “Big-Oh” notation. [2 marks]

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

5. a. 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).

b. Analyze the running time of your algorithm.

[2 marks]

### Marking Criteria for Assignments

Total marks = 10

· Application of the major and   alternative approaches, methods, or algorithms to solve the problem.

· Evidence of appropriate   logic.

· Evidence of correct   computational skills and data structures.

· Inclusion of appropriate   comments or explanations.

For details about how to submit this assignment, refer to the “Assignment Submission Instructions” under the Assignments Overview tab of your course.

Basic features
• Free title page and bibliography
• Unlimited revisions
• Plagiarism-free guarantee
• Money-back guarantee
On-demand options
• Writer’s samples
• Part-by-part delivery
• Overnight delivery
• Copies of used sources
Paper format
• 275 words per page
• 12 pt Arial/Times New Roman
• Double line spacing
• Any citation style (APA, MLA, Chicago/Turabian, Harvard)

# Our guarantees

We value our customers and so we ensure that what we do is 100% original..
With us you are guaranteed of quality work done by our qualified experts.Your information and everything that you do with us is kept completely confidential.

### Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

### Zero-plagiarism guarantee

The Product ordered is guaranteed to be original. Orders are checked by the most advanced anti-plagiarism software in the market to assure that the Product is 100% original. The Company has a zero tolerance policy for plagiarism.

### Free-revision policy

The Free Revision policy is a courtesy service that the Company provides to help ensure Customer’s total satisfaction with the completed Order. To receive free revision the Company requires that the Customer provide the request within fourteen (14) days from the first completion date and within a period of thirty (30) days for dissertations.

The Company is committed to protect the privacy of the Customer and it will never resell or share any of Customer’s personal information, including credit card data, with any third party. All the online transactions are processed through the secure and reliable online payment systems.

### Fair-cooperation guarantee

By placing an order with us, you agree to the service we provide. We will endear to do all that it takes to deliver a comprehensive paper as per your requirements. We also count on your cooperation to ensure that we deliver on this mandate.

## Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
\$26
The price is based on these factors: