announcements‎ > ‎

2015-11-19 HW-PTC

posted Nov 18, 2015, 7:44 PM by Samuel Konstantinovich   [ updated Nov 19, 2015, 6:23 AM ]

Parent Teacher Conferences: 

I will not be here either day. Please let your parents know about this document:

Parent Teacher Contact Document

Remember row vs col:
                 Col 0     Col 1   Col 2
Row 0        a[0][0]   a[0][1] a[0][2]
Row 1        a[1][0]   a[1][1] a[1][2]
Row 2        a[2][0]   a[2][1] a[2][2]
Row 3        a[3][0]   a[3][1] a[3][2]

Practice problems/Homework, due Monday. 
Place the files in the ~/apcs/hwPTC/  directory.

2D Array Practice:

public class ArrayMethods{
   public static int max(int[][] AR) {}
    //returns the maximum value in the 2d parameter array AR.

   public static int rowSum(int[][] AR, int x){}
    //returns the sum of the elements in Row x of AR. 

   public static int columnSum(int[][] AR, int x){}
    //returns the sum of the elements in Column x of AR (careful with rows of different lengths!).

   public static int[] allRowSums(int[][] AR){}
    //calculates the row sum for every row and returns each of the values in an array. 
    //Index i of the return array contains the sum of elements in row i.

   public static boolean isRowMagic(int[][] AR){}
     //checks if the array is row-magic (this means that every row has the same row sum).

   public static boolean isColumnMagic(int[][] AR){}
    //checks if the array is column-magic (this means that every column has the same column sum).

   public static boolean isSquare(int[][] AR){}
    //checks if the array is square (i.e. every row has the same length as AR itself).
}

ArrayList Practice:

//Usted debe llamar su class ArrayListMethods, 
//para que yo verificar que functiona propriamente.

import java.util.*;

public class ArrayListMethods{

    /*Remove any consecutive duplicates in the ArrayList
    *@param L The values which may contain duplicates 
    */
    public static void collapseDuplicates( ArrayList<Integer> L ) { }

    /*Change the order of the elements of L into a random permutation
    *@param L The values to be put into random order
*/ public static void randomize( ArrayList<Integer> L) { 
    }
    //How many operations do you perform on a list of size N? (in terms of N)
    //How much extra space did you use in order to complete this problem? (in terms of N)
    //Try to use less space/fewer operations. 
    //->The minimum would be NO extra space, and just k*N operations, for a small integer k.
    
public static void main(String[]args){ //test your functions here. } }
Comments