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