Lab 9: Week of Sep 29-Oct 05
 


Write a class array which has following methods: 

public static int[] reverse(int a[])

reverses sequence of elements in an array. For example if reverse is called with {1 4 9 16 9 7 4 9 11} then the array is changed to {11 9 4 7 9 16 9 4 1}

public static int[] append(int a[], int b[])

appends one array after another. For example if a is {1 4 9 16} and b is {9 7 4 9 11} then append returns the array {1 4 9 16 9 7 4 9 11}

public static boolean equals(int a[], int b[])

checks whether two arrays have the same elements in the same order

public static boolean SameSet(int a[], int b[])

tests whether two arrays have same elements (ignoring order and multiplicities)

public static boolean SameElements(int a[], int b[])

tests whether two arrays have same elements (ignoring order) with the same multiplicities

public static int[] subtract(int a[], int b[])

removes elements from a which are in b. After removing all the elements array a should be compacted i.e. if only n elements are left in a after subtraction then they should occur at indices from 0 to n-1

Use helper functions wherever needed.