{"id":231,"date":"2014-05-26T23:52:42","date_gmt":"2014-05-27T03:52:42","guid":{"rendered":"http:\/\/josephpcohen.com\/cs210-summer2014\/?p=231"},"modified":"2014-05-26T23:52:42","modified_gmt":"2014-05-27T03:52:42","slug":"hw2","status":"publish","type":"post","link":"https:\/\/josephpcohen.com\/teaching\/cs210\/hw2\/","title":{"rendered":"HW2 : Circular Array Queue"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Due: Monday 6\/9\/14 @5:30pm<\/p>\n<p><strong>Purpose:<\/strong> This homework gives you experience developing a class that implements a java.util.Queue using a circular array.<\/p>\n<p><strong>Activities:<\/strong><\/p>\n<p>You need to design and add code to the methods of the CircularArrayQueue class (which extends QueueADT not java.util.Queue) in places as indicated by the comments:<\/p>\n<p>1. In the constructor(int initialCapacity), you need to instantiate the array and initialize the attributes: front, rear, and count.<\/p>\n<p>2. In the enqueue method, you need to add an element to the array in the correct place based on the state of the circular array.<\/p>\n<p>3. In the dequeue method, you need to return an alias of the reference to the first element in the queue and remove it.<\/p>\n<p>4. In the first method, you need to return an alias of the reference to the first element in the queue.<\/p>\n<p>5. In the enqueue method, you need to add a check for the need to expand capacity before updating the queue array and if needed, call the private expandCapacity method.<\/p>\n<p>6. In the private expandCapacity method, you need to add the code to instantiate a new array twice the size of the existing array and copy all of the contents of the smaller array into the larger array so that the next element can be added.<\/p>\n<p>7. Write a file memo.txt that discusses the challenges you faced, how to solved them or not, and what you learned from the assignment.<\/p>\n<p><strong>Download the code needed:<\/strong> <a href=\"http:\/\/josephpcohen.com\/cs210-summer2014\/wp-content\/uploads\/hw2.zip\">hw2<\/a><\/p>\n<pre>\/\/to compile with junit\njavac -cp .:junit.jar *.java\n\/\/to run the test cases\njava -cp .:junit.jar junit.textui.TestRunner QueueTest\njava -cp .:junit.jar junit.textui.TestRunner QueueExpandTest\n<\/pre>\n<p><strong>To Deliver:<\/strong><\/p>\n<p>On the UNIX system in a folder called &#8216;hw2&#8217; put the following files (or more):<\/p>\n<p>CircularArrayQueue.java, memo.txt<\/p>\n<p>These files can also be in an &#8216;src&#8217; folder so that you can use the folder as an eclipse project.<\/p>\n<p><strong>Grading (total 10 points):<\/strong><\/p>\n<p>2 points: Implement enqueue (testEnqueuingNoWrap)<\/p>\n<p>2 points: Implement dequeue (testDequeuingNoWrap)<\/p>\n<p>1 points: Implement enqueue with wrapping (testWrapAround)<\/p>\n<p>3 points: Implement expandCapacity (testExpandCapacity)<\/p>\n<p>2 points: memo.txt and how easy the assignment is to grade<\/p>\n<p>Homework derived from work by Professor Bob Wilson (UMass Boston)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Due: Monday 6\/9\/14 @5:30pm Purpose: This homework gives you experience developing a class that implements a java.util.Queue using a circular array. Activities: You need to design and add code to the methods of the CircularArrayQueue class (which extends QueueADT not java.util.Queue) in places as indicated by the comments: 1. In the constructor(int initialCapacity), you&#8230;  <a href=\"https:\/\/josephpcohen.com\/teaching\/cs210\/hw2\/\" class=\"more-link\" title=\"Read HW2 : Circular Array Queue\">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\/cs210\/wp-json\/wp\/v2\/posts\/231"}],"collection":[{"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/comments?post=231"}],"version-history":[{"count":0,"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/posts\/231\/revisions"}],"wp:attachment":[{"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/media?parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/categories?post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/josephpcohen.com\/teaching\/cs210\/wp-json\/wp\/v2\/tags?post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}