A community for students.
Here's the question you clicked on:
 0 viewing
s3a
 4 years ago
I have no idea how to begin for this:
In general, what would be the average running time of the merge sort method for computing the intersection between two lists of n students (assuming n>=32000)? Give your answers as a function of n (e.g. T(n) = 43 n + 5 log(n) milliseconds).
Could someone please help?
s3a
 4 years ago
I have no idea how to begin for this: In general, what would be the average running time of the merge sort method for computing the intersection between two lists of n students (assuming n>=32000)? Give your answers as a function of n (e.g. T(n) = 43 n + 5 log(n) milliseconds). Could someone please help?

This Question is Closed

shadowfiend
 4 years ago
Best ResponseYou've already chosen the best response.0Hm. Do you know what the merge sort method for computing the intersection is?

shadowfiend
 4 years ago
Best ResponseYou've already chosen the best response.0Presumably you sort both lists and then go through piecewise. Assuming merge sort is considered to be T(n) = n log(n) (the usual running time attributed to merge sort), how many additional runs do you have to do through the lists to check what corresponding items there are?

shadowfiend
 4 years ago
Best ResponseYou've already chosen the best response.0The only weird thing about this is that merge sort implies there's an ordering to these students.

shadowfiend
 4 years ago
Best ResponseYou've already chosen the best response.0But I think we're looking at T(n) = 2n + n log(n). Because let's assume the two lists have no items in common, but they alternate which one has an item that is greater than the other. Then you'd have to keep switching between each list to check if there are any correspondences and end up going through each of them once.

shadowfiend
 4 years ago
Best ResponseYou've already chosen the best response.0But that may be a worst case so average may be n + n log(n)

asnaseer
 4 years ago
Best ResponseYou've already chosen the best response.0There is an interesting article here on this topic: http://www.iti.fhflensburg.de/lang/algorithmen/sortieren/merge/mergen.htm which states: "This yields a running time of mergesort of at most 1.5n log(n) steps."

shadowfiend
 4 years ago
Best ResponseYou've already chosen the best response.0Cool. The missing piece here is of course computing the intersection. Although now that I think about it, what is the intersection but essentially a last application of the merge step with some slightly different logic? So possibly 1.5n + n log(n)?

mathmate
 4 years ago
Best ResponseYou've already chosen the best response.3Students usually have a unique numeric id. I believe that was assumed in the question. I think by intersection the question means finding ALL intersections, so we have 2nlogn for sorting 2 lists each of length n, and 2n for going through them once for at total of 2nlogn+2n.

shadowfiend
 4 years ago
Best ResponseYou've already chosen the best response.0Derp. Two lists, two sorts. Good catch hehe.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.