import Myro.*; public class ArrayPratice { private static final int INITIALNUM = 10; private static final int MAX = 100; private int[ ] myNumbers = new int[MAX]; private int top = 0; //Initialize a sorted array. It will have INITIALNUM elements. //top will have the value of the first uninitialized element public ArrayPratice() { System.out.println(); System.out.println(); for (int i=0; i= MAX) return false; myNumbers[top++] = toAdd; //assign into position "top" and then increase top by 1 return true; } //Add a number, toAdd, into the first spot in the array //(position 0). //top will increase by one //all other array elements will shift upwards //return true iff successful //Assume array is UNSORTED public boolean insertFirst(int toAdd) { if (top >= MAX) return false; insertLast(myNumbers[0]); myNumbers[0] = toAdd; return true; } //Return the index of the first occurance of the number //toFind in the array. If it does not appear in the //array, return -1 //Assume array is UNSORTED public int findElt(int toFind) { for (int i=0; i= MAX) return false; //find the first number that's greater than toFind for (int i=0;i toFind) location = i; //if I never found a number bigger than toFind, toFind should go at the end of the array if (location == -1) insertLast(toFind); else { for (int i=top; i>location; i--) myNumbers[i] = myNumbers[i-1]; myNumbers[location] = toFind; top++; } return true; } }