For your add (should be called insert?) method:
1. You have to first figure out what index they want to add the item at. If the index they want to add the item at is the empty, then just insert it and you're done.
2. If the index is not empty, and your array is large enough to add an item, then you have to move every element after that index down. You have to start at the last filled index and move it down first. Then move the one next to it into it's place, and do this until you can add the item you want to add. You have to start at the very end so that you don't overwrite any items.
3. If you do not have an array large enough, you have to create a new array with enough space, then copy the elements over in the correct spots.
I hope that explanation helps. If you need an example, I can try to give you one, but it's hard to draw it.
Last edited by BestJewSinceJC; Mar 31st, 2009 at 6:42 pm.
Reputation Points: 874
Solved Threads: 352
Posting Maven
Offline 2,758 posts
since Sep 2008