Analysis of Algorithms

In all cases explain clearly and as succinctly as possible.

Problem 1

Answer: n T (n) = 2T ( n ) + log n 2 2 n = 4T ( n ) + logn n + log n 4 2 2 2 n = 4T ( n ) + log nn−1 + log n 4 2 2 = … ∑log2 n 1 = nT (1) + n i=1 i ∑n Since i=1 1 → ln n, T (n) ∈ Θ(n log log n) i

Problem 2

Answer: The general idea is to use the technique similar to quicksort, by doing partition on both lids and cups.

First, we pick a cup randomly and use it to partition the lids into two subsets: those lids smaller than the size of that cup, and those larger than the size of the cup. We can also find the corresponding lid for that chosen cup. Second, we use that lid to partition the cups and divide them into two sets. We keep on repeating this procedure on each subset of cups/lids until all the cups/lids are paired. The overall time complexity is O(n log n) (Worst case: O(n2 )).

Problem 3

Answer: In this problem, we are more interested in finding the median instead of the minimum/maximum element. The ⌊ n ⌋th element in a min/max heap is not the median. 2 In this case, we should develop a new type of heap to adapt to this problem. Problem 3 2 The solution is to use two heaps: a min-heap and a max heap. Suppose the total number of elements is n, we set the restriction that the max heap should contain ⌊ n ⌋ 2 elements. Correspondingly, the min-heap contains n – ⌊ n ⌋ elements. 2 When we insert an element, we always insert it into the max heap.

If the number of elements in the max heap exceeds ⌊ n ⌋, we remove the maximum element in the 2 max heap (the root) and insert it into the minimum heap. During this procedure, we need to do heapify to maintain the heap structure for both heaps. Under this setting, it is easy to see that all the elements in the max heap are less than those in the min-heap, and the two elements at the root of both heaps represent the ⌊ n ⌋th 2 and (⌊ n ⌋ + 1)th element.

2 Suppose the median is de? ned to be the ⌊ n ⌋th element overall n elements.

When 2 we delete the median, we just delete the root of the max heap, and the following two cases might occur: (1) If the max heap contains ⌊ n ⌋ 1 – elements, then we do delete-max to the max 2 heaps. (2) If the max heap contains ⌊ n  – 1 ⌋ – 1 elements, we take out the root of the min 2 heap and set it to be the root in the max heap (because it is larger than all the elements in the max heap), then we do delete-min to the min-heap. It is straightforward to see that the time complexity for both insert and delete-median is O(log n).

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with MyStudyWriters
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Nursing
I just need some minor alterations. Thanks.
Customer 452547, February 10th, 2021
Business and administrative studies
excellent job!
Customer 452773, May 25th, 2023
Business and administrative studies
Excellent work ,always done early
Customer 452773, February 21st, 2023
Criminal Justice
The paper was not accused of plagiarism and was written very well. I will let you know the grade once it is graded. Thank you
Customer 452671, April 26th, 2021
History
Don't really see any of sources I provided, but elsewise its great, thank you!
Customer 452697, May 8th, 2021
Business and administrative studies
excellent, got a 100
Customer 452773, May 17th, 2023
Business and administrative studies
Thank you
Customer 452773, March 19th, 2023
Business and administrative studies
excellent paper
Customer 452773, March 3rd, 2023
Leadership Studies
awesome work as always
Customer 452773, August 19th, 2023
Nursing
Impressive writing
Customer 452547, February 6th, 2021
Humanities
Thank youuuu
Customer 452729, May 30th, 2021
Business and administrative studies
excellent job
Customer 452773, March 12th, 2023
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat
Close

Sometimes it is hard to do all the work on your own

Let us help you get a good grade on your paper. Get professional help and free up your time for more important courses. Let us handle your;

  • Dissertations and Thesis
  • Essays
  • All Assignments

  • Research papers
  • Terms Papers
  • Online Classes
Live ChatWhatsApp