Homework 3 (The Amazing Deque) FAQ

Q: What are some good resources or examples I can look at to get started on this program?
A: Look at the ArrayStack and LinkedStack examples from lecture. If you want to read more about implementing a collection using an array, you can read this sample Building Java Programs Chapter 15 on implementing an ArrayIntList and ArrayList class (please do not distribute!). (The ArrayList implemented in the BJP chapter is not exactly the same as your ArrayDeque, because it is not a circular buffer; but reading that chapter may give you some general insights about implementing collection classes using an array as the internal data structure.)
Q: On Part A, my maze solver doesn't exactly match the output comparison tool, though it's very similar. Why would mine have small differences?
A: You may be exploring the neighbors in a different order than our algorithm does. Ours looks at the neighbors in this order: up (y-1), down (y+1), left (x-1), right (x+1). It may not make a difference for grading, but if you want to exactly match our output for your own peace of mind, use that order.
Q: On Part B, I get a compiler warning when I try to cast Object[] into E[]. Is that okay? What should I do?
A: That's just a Java thing; you have to receive that error when you cast an array into a generic type. You can either ignore it or add @SuppressWarnings("unchecked") above your method/constructor header to remove the error. This is okay and acceptable style in this one particular case. (Please don't use @SuppressWarnings elsewhere, only in this particular situation.)
Q: On Part B, my circular array seems to get messed up and crashes or produces the wrong results. But how do I figure out what is wrong and fix it?
A: You could use a debugger, like the ones found in Eclipse and jGRASP, to step through your code. And/or you can insert temporary println statements in your deque class to see your internal state. Print your array and any other fields/variables and track how they change on each add/remove operation. You can print the contents of an array like this:
This document and its content are copyright © Marty Stepp, 2013. All rights reserved.
Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form
is prohibited without the author's expressed written permission.