{"id":238,"date":"2015-06-19T15:42:44","date_gmt":"2015-06-19T15:42:44","guid":{"rendered":"http:\/\/josephpcohen.com\/teaching\/cs310\/?p=238"},"modified":"2015-06-19T16:16:46","modified_gmt":"2015-06-19T16:16:46","slug":"hw2","status":"publish","type":"post","link":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/hw2\/","title":{"rendered":"HW2"},"content":{"rendered":"<p><\/p>\n<p>1. Given an array of non-negative integers, you are initially positioned at the first index of the array.<\/p>\n<p>Each element in the array represents your maximum jump length at that position.<\/p>\n<p>Your goal is to reach the last index in the minimum number of jumps.<\/p>\n<p>For example:<br \/>\nGiven array A = [2,3,1,1,4]<\/p>\n<p>The minimum number of jumps to reach the last index is 2. (Jump 1 step from index 0 to 1, then 3 steps to the last index.)<\/p>\n<p>Write code to solve this problem. Your code should run as follows:<\/p>\n<pre>$java Jump 2 3 1 1 4\r\n2\r\n<\/pre>\n<p>2. Given a collection of intervals, merge all overlapping intervals.<\/p>\n<p>For example,<\/p>\n<p>Given [1,3],[2,6],[8,10],[15,18]<\/p>\n<p>return [1,6],[8,10],[15,18].<\/p>\n<p>Write code to solve this problem. Your code should run as follows:<\/p>\n<pre>$java Merge 1 3 2 6 8 10 15 18\r\n[1,6],[8,10],[15,18]\r\n<\/pre>\n<p>3. Describe a family of graphs with V vertices and E edges for which the worst-case running time of Dijkstra\u2019s algorithm is achieved.<\/p>\n<p>4. Suppose you\u2019re consulting for a bank that\u2019s concerned about fraud detection, and they come to you with the following problem. They have a collection of n bank cards that they\u2019ve confiscated, suspecting them of being used in fraud. Each bank card is a small plastic object, containing a magnetic stripe with some encrypted data, and it corresponds to a unique account in the bank. Each account can have many bank cards corresponding to it, and we\u2019ll say that two bank cards are equivalent if they correspond to the same account.<\/p>\n<p>It\u2019s very difficult to read the account number off a bank card directly, but the bank has a high-tech \u201cequivalence tester\u201d that takes two bank cards and, after performing some computations, determines whether they are equivalent.<br \/>\nTheir question is the following: among the collection of n cards, is there a set of more than n\/2 of them that are all equivalent to one another? Assume that the only feasible operations you can do with the cards are to pick two of them and plug them in to the equivalence tester. Show how to decide the answer to their question with only O(n log n) invocations of the equivalence tester.<\/p>\n<p>Due: 6\/25 @5pm. Submit the code to users in .java files and the written answers in a memo.txt. Each question is two points and then 2 points for how easy it is to grade.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. For example: Given array A = [2,3,1,1,4] The minimum number&#8230;  <a href=\"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/hw2\/\" class=\"more-link\" title=\"Read HW2\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[],"_links":{"self":[{"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/posts\/238"}],"collection":[{"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/comments?post=238"}],"version-history":[{"count":6,"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":244,"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/posts\/238\/revisions\/244"}],"wp:attachment":[{"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/media?parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/categories?post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs310-summer2015\/wp-json\/wp\/v2\/tags?post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}