CMPSCI 187 / Spring 2015 Hanoi

Similar documents
CMPSCI 187 / Spring 2015 Sorting Kata

CMPSCI 187 / Spring 2015 Hangman

CMPSCI 187 / Spring 2015 Postfix Expression Evaluator

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

COMPSCI 220 Programming Methodology Project Assignment 06: Expression Evaluator

Com S 227 Assignment Submission HOWTO

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Assignment Submission HOWTO

CmpSci 187: Programming with Data Structures Spring 2015

Project 3: Implementing a List Map

Laboratory 1: Eclipse and Karel the Robot

Lab Exercise 6: Abstract Classes and Interfaces CS 2334

15-110: Principles of Computing, Spring 2018

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

Web-CAT Guidelines. 1. Logging into Web-CAT

Tips from the experts: How to waste a lot of time on this assignment

CMSC 201 Spring 2019 Lab 06 Lists

Our second exam is Thursday, November 10. Note that it will not be possible to get all the homework submissions graded before the exam.

CSE 143: Computer Programming II Summer 2017 HW5: Anagrams (due Thursday, August 3, :30pm)

CSSE2002/7023 The University of Queensland

Tips from the experts: How to waste a lot of time on this assignment

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15

Programming and Data Structure

CS201 - Assignment 3, Part 1 Due: Friday February 28, at the beginning of class

CSIS 10B Lab 2 Bags and Stacks

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

Our second exam is Monday, April 3. Note that it will not be possible to get all the homework submissions graded before the exam.

Tips from the experts: How to waste a lot of time on this assignment

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

CSE 143: Computer Programming II Winter 2019 HW6: AnagramSolver (due Thursday, Feb 28, :30pm)

Moodle 2.2 Student User Guide My Private Files

CMPSCI 187: Programming With Data Structures. Lecture #15: Thinking Recursively David Mix Barrington 10 October 2012

IBM WebSphere Java Batch Lab

Assignment 5: Part 1 (COMPLETE) Sprites on a Plane

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Homework Assignment #3

CISC 181 Lab 2 (100 pts) Due: March 4 at midnight (This is a two-week lab)

Lab Exercise 4: Inheritance and Polymorphism CS 2334

Lecture Notes 4 More C++ and recursion CSS 501 Data Structures and Object-Oriented Programming Professor Clark F. Olson

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

15-110: Principles of Computing, Spring 2018

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class

Project 8: Virtual Machine Translator II

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Com S 227 Spring 2018 Assignment points Due Date: Thursday, September 27, 11:59 pm (midnight) "Late" deadline: Friday, September 28, 11:59 pm

Mehran Sahami Handout #5 CS 106A September 27, 2017 Downloading Eclipse

Total Score /15 /20 /30 /10 /5 /20 Grader

CSC D84 Assignment 2 Game Trees and Mini-Max

Total Score /15 /20 /30 /10 /5 /20 Grader

COSC-211: DATA STRUCTURES HW5: HUFFMAN CODING. 1 Introduction. 2 Huffman Coding. Due Thursday, March 8, 11:59pm

Laboratory Assignment #3 Eclipse CDT

Unate Recursive Complement Algorithm

Programming Project 1

Assignment #1 Simple C++

CS 134 Programming Exercise 3:

CMSC 201 Spring 2018 Project 3 Minesweeper

CS ) PROGRAMMING ASSIGNMENT 11:00 PM 11:00 PM

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

CS451 - Assignment 3 Perceptron Learning Algorithm

Recursive Definitions

Homework 6: Higher-Order Procedures Due: 10:00 PM, Oct 17, 2017

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE. Speaking the Language of OO

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

Project 6: Assembler

CMSC 201 Spring 2017 Lab 05 Lists

Computer. CSE 373 Summer 2017 Due 5:00pm on Friday, July 14th

ECE/CS 541: COMPUTER SYSTEMS ANALYSIS. Homework #4 Due Tuesday, October 6, 2009

ENCE 3241 Data Lab. 60 points Due February 19, 2010, by 11:59 PM

ECE2049 Embedded Computing in Engineering Design. Lab #0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

USING DRUPAL. Hampshire College Website Editors Guide

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

Programming Project 5: NYPD Motor Vehicle Collisions Analysis

There are several files including the start of a unit test and the method stubs in MindNumber.java. Here is a preview of what you will do:

CSCI 135 Programming Exam #1 Fundamentals of Computer Science I Fall 2014

Programming Assignment 2

Lesson 10: Quiz #1 and Getting User Input (W03D2)

Compilers. Computer Science 431

Cmpt 101 Lab 1 - Outline

CS 2110 Summer 2011: Assignment 2 Boggle

CSCI 102L - Data Structures Midterm Exam #2 Spring 2011

EUSurvey OSS Installation Guide

CIS 121 Data Structures and Algorithms with Java Spring 2018

Moodle 2 Importing Courses from Moodle 1.9

, has the form T i1i 2 i m. = κ i1i 2 i m. x i1. 1 xi2 2 xim m (2)

Mehran Sahami Handout #5 CS 106A September 26, 2018 Downloading Eclipse

CSCI 3155: Homework Assignment 3

15-110: Principles of Computing, Spring 2018

XC Total Max Score Grader

COMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE. Instructor: Prasun Dewan (FB 150,

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle

- 1 - Handout #33 March 14, 2014 JAR Files. CS106A Winter

CSCI 201 Lab 1 Environment Setup

Using Karel with Eclipse

Homework 6: Higher-Order Procedures Due: 11:59 PM, Oct 16, 2018

EE 422C HW 6 Multithreaded Programming

The following steps will create an Eclipse project containing source code for Problem Set 1:

Transcription:

Due on Thursday, March 12, 2015, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1

Contents Overview 3 Learning Goals................................................. 3 General Information 3 Policies..................................................... 3 Test Files.................................................... 3 Import Project into Eclipse........................................... 4 Problem 1 5 Basic Recursion Warmup............................................ 5 Problem 2 5 Implement ListInterface......................................... 5 Problem 3 6 Code Overview................................................. 6 Implement the Tower of Framework................................... 6 Export and Submit............................................... 7 Page 2 of 7

Overview For this assignment, you will implement a few algorithms recursively. Then, you ll implement a generic collection. Finally, you ll implement both the Tower of game and a solution generator for that game. Learning Goals Practice implementing simple recursive methods, including mutually (indirectly) recursive methods. Show ability to write a generic class that implements a given interface, fulfilling the contract it specifies (including O() behavior and an Iterable implementation). Model the Towers of game and its solution using appropriate data structures and abstractions (e.g., stacks and lists). Write a recursive solver for the Towers of game. General Information Read this entire document. If, after a careful reading, something seems ambiguous or unclear to you, then email cs187help@cs.umass.edu immediately. Start this assignment as soon as possible. Do not wait until 5pm the night before the assignment is due to tell us you don t understand something, as our ability to help you will be minimal. Reminder: Copying partial or whole solutions, obtained from other students or elsewhere, is academic dishonesty. Do not share your code with your classmates, and do not use your classmates code. You are responsible for submitting project assignments that compile and are configured correctly. If your project submission does not follow these policies exactly you may receive a grade of zero for this assignment. Policies For some assignments, it will useful for you to write additional class files. Any class file you write that is used by your solution MUST be in the provided src directory you export. The TAs and instructors are here to help you figure out errors, but we won t do so for you after you submit your solution. When you submit your solution, be sure to remove all compilation errors from your project. Any compilation errors in your project will cause the autograder to fail, and you will receive a zero for your submission. Test Files In the test directory, we provide several JUnit test cases that will help you keep on track while completing the assignment. We recommend you run the tests often and use them to help create a checklist of things to do next. But you should be aware that we deliberately don t provide you the full test suite we use when grading. Page 3 of 7

We recommend that you think about possible cases and add new @Test cases to these files as part of your programming discipline. Simple tests to add will consider questions such as: Do your methods taking integers as arguments handle positives, negatives, and zeroes (when those values are valid as input)? Does your code handle unusual cases, such as empty or maximally-sized data structures? More complex tests will be assignment-specific. To build good test cases, think about ways to exercise methods. Work out the correct result for a call of a method with a given set of parameters by hand, then add it as a test case. Note that we will not be looking at your test cases, they are just for your use. Before submitting, make sure that your program compiles with and passes all of the original tests. If you have errors in these files, it means the structure of the files found in the src directory have been altered in a way that will cause your submission to lose some (or all) points. Import Project into Eclipse Begin by downloading the starter project and importing it into your workspace. It is very important that you do not rename this project as its name is used during the autograding process. If the project is renamed, your assignment will not be graded, and you will receive a zero. The imported project may have some errors, but these should not prevent you from getting started. Specifically, we may provide JUnit tests for classes that do not yet exist in your code. You can still run the other JUnit tests. The project should normally contain the following root items: src This is the source folder where all code you are submitting must go. You can change anything you want in this folder (unless otherwise specified in the problem description and in the code we provide), you can add new files, etc. support This folder contains support code that we encourage you to use (and must be used to pass certain tests). You must not change or add anything in this folder. To help ensure that, we suggest that you set the support folder to be read-only. You can do this by right-clicking on it in the package explorer, choosing Properties from the menu, choosing Resource from the list on the left of the pop-up Properties window, unchecking the Permissions check-box for Owner-Write, and clicking the OK button. A dialog box will show with the title Confirm recursive changes, and you should click on the Yes button. test The test folder where all of the public unit tests are available. JUnit 4 A library that is used to run the test programs. JRE System Library This is what allows Java to run; it is the location of the Java System Libraries. If you are missing any of the above or if errors are present in the project (other than as specifically described below), seek help immediately so you can get started on the project right away. Note: It is expected that there will be three errors in the project as distributed, visible in the Problems tab in Eclipse. Each relates to the ListImplementation class, and all will be resolved once you ve completed Problem 2. Page 4 of 7

Note: You may not use any of the classes from the Java Platform API that implement the Collection interface (or its sub-interfaces, etc.). The list of these classes is included in the API documentation, available at: http: //docs.oracle.com/javase/7/docs/api/java/util/collection.html. Doing so will be viewed as an attempt to cheat. Problem 1 Basic Recursion Warmup Start off by completing the algorithms.recursivemath class you will find in the src directory. You must implement each method in this class using recursion. Nowhere in this class may you use loops; i.e., you must not use for, while, or do statements. Your code may not cast values to other types it must operate only on ints. Nor may you use the java.util.math class. The private tests will be smart enough to detect violations of these requirements, and at best you will receive a zero for the entire project if you violate them. iseven and isodd For your implementation of the iseven and isodd methods, you must not use the % operator. Your code must handle negative values. Hint: What does iseven(0) return? What does isodd(1) return? What does iseven(2) return? You may want to use isodd in your definition of iseven and vice versa. sumn For your solution, you must not use the *, /, *=, or /= operators. Hint: Read about factorial at the end of Section 4.1. The solution to this one is pretty similar! factorial Read about factorial at the end of Section 4.1. bipower Hint: This one is also very similar to factorial! Problem 2 It may be useful for you to write additional class files. Any class file you write that is used by your solution MUST be in the provided src folder. When we test your assignment, all files not included in the src folder will be ignored. Implement ListInterface Take a mental break from recursion and work on something you should be quite familiar with: lists! You will need to implement the structures.listinterface provided. Make sure to read over the comments carefully; you are being tested on how well you implement the stated contract. You should implement the ListInterface in a class ListImplementation, and you should locate that class in the structures package under src. Problem 2 continued on next page... Page 5 of 7

Problem 2 (continued) You will notice that the size and append methods must execute in O(1) time. This means you will not pass the tests if you iterate down your links to calculate the size or to append an element. You will have to find another way to do this. You are now adding a get method. The method should take O(n) time where n is the index of the element being returned. One valid approach is to iterate to the specified location on your list and then return the element. You are also adding an iterator() method, which means that you will need to implement a class that implements Iterator for your iterator() method to return. Problem 3 It may be useful for you to write additional class files. Any class file you write that is used by your solution MUST be in the provided src folder. When we test your assignment, all files not included in the src folder will be ignored. Code Overview In the support directory you will find provided three classes, Move, Ring, and Solution, that must not be modified. In addition there is an exception class IllegalMoveException, and two interfaces, Board, and Peg. Corresponding to the interfaces in the support directory are skeleton classes in the src directory for you to complete. ArrayBasedBoard implements the Board interface, and StackBasedPeg implements the Peg interface. The src directory also contains a skeleton of the RecursiveSolver class. You must correctly complete all three of these classes. We are also providing you with a StackInterface interface and a LinkedStack implementation of that interface. You must not change these but you are welcome to use them. Implement the Tower of Framework In this section, you will be implementing a framework for the creating a Tower of puzzle game. The Tower of puzzle is presented in Section 4.3 of DJW. Start by reviewing how the game works and then reading the interfaces and classes provided. Perhaps draw some pictures to show how each of the classes relates to one another before you start. This will help you become familiarized with their functionality. We suggest you complete the skeleton classes in this order: StackBasedPeg, then ArrayBasedBoard, because it uses StackBasedPeg, and finally RecursiveSolver, which uses the other two. When we say complete, we mean you should be as certain as possible that each is correct before moving on to the next minimally, each should be passing all of the supplied tests before you move to the next. Problem 3 continued on next page... Page 6 of 7

Problem 3 (continued) StackBasedPeg Does this class look familiar in some way? Perhaps you can use some code we ve provided as part of your implementation. ArrayBasedBoard This class should be straightforward to finish. Imagine if you build an actual Tower of puzzle. How would you interact with it in real life? The name of this class is a hint, but not a requirement, about how you might organize the group of three pegs. RecursiveSolver In this class, you must implement a recursive algorithm to generate a solution to the Tower of puzzle. You must not use loops in your implementation (and trust us, you don t want to try). You should definitely read (and then re-read) Section 4.3 of the book. Make sure you understand how to solve the puzzle in and out. You will notice that the solve method actually returns an instance of Solution. This class is simply a wrapper containing a value representing how one should set up the Tower of puzzle and then a list of moves to make to complete the puzzle. Export and Submit When you have completed the changes to your code, you should export an archive file containing the entire Java project. To do this, click on the hanoi-student project in the package explorer. Then choose File Export from the menu. In the window that appears, under General choose Archive File. Then choose Next and enter a destination for the output file. Be sure that the project is named hanoi-student. Save the exported file with the zip extension (any name is fine). Log into Moodle and submit the exported zip file. Page 7 of 7