Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

220: o gorith Thursday October t e iti Clas8 17pt Return the homework writ ten on sheet(s) write the solution on your ow Also you

image text in transcribed
220: o gorith Thursday October t e iti Clas8 17pt Return the homework writ ten on sheet(s) write the solution on your ow Also you lait Problem 1: You are given two sets A and stach that S contain all the singles (e, elemes doubles (Le. elements appearing in both A and l O(n) where n-IA] + IB:) lo points from a swt Create tw Vists D n s shoulkd run in expertod lines tse a new office in Manhattan Becauseth U or only in B, and D 4 appear only in Problem 2: The law firm of Gennaro & Geu often haver to hand deliver important panthtoats the sum of the distances between their new fets locations. They hssve n elicuts C % pokinshey are lookingfor a kration that minimizes where esch client is represented by a pitt we travel on a grid, the distance between the blar.u) and the client loeation is w.). Becaase this is Manhattan whrre computed 6(x, y) . Give an algorithm that computes the aborehotion in O(n) time. . A very smart intern at the firm notices clients that sene clients receive parcels ore often than He suggests to theartners that the right quantityu to minimiz ihern. He o.C) where fi is the frequeney with which client f,S1and.-imin heives parcels. In other wordsthe f's are real such that 0: minimizes the above quantity. Your algorithtn should still work in O(n) time. Hint:For the first part, use the median algorithm. To simplify things consider first the one-dimensional case in which points are on a line, not on the plane. Each client isingle coordinate C,-z, and the distance islz-11 Does the median of the r, minimize the distance? Hose can you use the one-dimensional case to solre the 2-dimensional problem? For the second part, modify the notion of median to take into account the frequencies. Assume eithout loss of generality that n is an odd number. Problem 3: At the end of the academic year CUNY will issue a sorted list of all its Computer Science students, ranked by the ir score on the Algorithms course. For each seetion of the course, been asked to return a sorted list of the students in that section according to their score. At the end of the year CUNY will have k sorted lists (one for each section), with n students in total. Show how to produce the total sorted list in O(n log k) steps 220: o gorith Thursday October t e iti Clas8 17pt Return the homework writ ten on sheet(s) write the solution on your ow Also you lait Problem 1: You are given two sets A and stach that S contain all the singles (e, elemes doubles (Le. elements appearing in both A and l O(n) where n-IA] + IB:) lo points from a swt Create tw Vists D n s shoulkd run in expertod lines tse a new office in Manhattan Becauseth U or only in B, and D 4 appear only in Problem 2: The law firm of Gennaro & Geu often haver to hand deliver important panthtoats the sum of the distances between their new fets locations. They hssve n elicuts C % pokinshey are lookingfor a kration that minimizes where esch client is represented by a pitt we travel on a grid, the distance between the blar.u) and the client loeation is w.). Becaase this is Manhattan whrre computed 6(x, y) . Give an algorithm that computes the aborehotion in O(n) time. . A very smart intern at the firm notices clients that sene clients receive parcels ore often than He suggests to theartners that the right quantityu to minimiz ihern. He o.C) where fi is the frequeney with which client f,S1and.-imin heives parcels. In other wordsthe f's are real such that 0: minimizes the above quantity. Your algorithtn should still work in O(n) time. Hint:For the first part, use the median algorithm. To simplify things consider first the one-dimensional case in which points are on a line, not on the plane. Each client isingle coordinate C,-z, and the distance islz-11 Does the median of the r, minimize the distance? Hose can you use the one-dimensional case to solre the 2-dimensional problem? For the second part, modify the notion of median to take into account the frequencies. Assume eithout loss of generality that n is an odd number. Problem 3: At the end of the academic year CUNY will issue a sorted list of all its Computer Science students, ranked by the ir score on the Algorithms course. For each seetion of the course, been asked to return a sorted list of the students in that section according to their score. At the end of the year CUNY will have k sorted lists (one for each section), with n students in total. Show how to produce the total sorted list in O(n log k) steps

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

=+free to pirate employees from competitors?

Answered: 1 week ago