Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/AMS/Regular/Main.js
JMU JMU - Department of Computer Science
Help Tools
Sample Questions for Exam 1


  1. Indicate whether each of the following statements is true or false:
    (1) _____ Geodesy is the science (and art) of communicating geodetic information using abstract visual representations (i.e., maps).
    (2) _____ A legend is an example of a geographic feature.
    (3) _____ Azimuthal projections are all conformal.
    (4) _____ Cylindrical projections use cylindrical coordinates.
    (5) _____ Some map projections are both conformal and equal area.
    (6) _____ Geocoding is the process of finding the coordinates of an object on the surface of the Earth.
  2. Answer all of the following questions.
    1. Visually illustrate the addition of two vectors in \mathbb{R}^{2}.
    2. Given p = (3,4) and q = (8,8), evaluate p \cdot q (i.e., the inner product of p and q).
    3. Given p = (6,8), evaluate ||p|| (i.e., the norm of p and q).
    4. Suppose you have a line through the points p=(0,2) and q=(1,1). Write the equation of this line in slope-intercept form.
  3. Show that the point (\theta, d) in polar coordinates (where \theta denotes the angular measure and d denotes the linear measure) can be written in Cartesian coordinates as (d \cos \theta, d \sin \theta).
  4. Complete the times method in the following CartesianPoint class:
    public class CartesianPoint
    {
        private double[]               value;
    
        private static final int       DIMENSION = 2;
        
    
    
        /**
         * Explicit Value Constructor
         *
         * @param x   The value of the horizontal coordinates
         * @param y   The value of the vertical coordinates
         */
        public Point(double x, double y)
        {
           value = new double[DIMENSION];
           value[0] = x;
           value[1] = y;
        }
    
    
    
    
    
        /**
         * Multiply this CartesianPoint by a scalar
         *
         * @param alpha  The scalar
         * @return       The result of the multiplication 
         */
        public CartesianPoint times(double alpha)
        {
    
    
    
    
    
    
    
        }
    
    }
        
  5. Assume that you have a Drafter class with the following two methods:
        /**
         * Draw a straight (solid black) line segment from the pen's current Point
         * (i.e., the result of the last moveTo() or drawTo())
         * to the given Point.  This method leaves the pen at p
         *
         * @param p    The end of the line segment
         */
        public void drawTo(CartesianPoint p)
        {
         ...
        }
    
    
        /**
         * Lift the pen off of the paper and move it to
         * the given Point
         *
         * @param p    The Point to move to
         */
        public void moveTo(CartesianPoint  p)
        {
           ...
        }
        

    what would be drawn by the following sequence of method calls?

        moveTo(new CartesianPoint(10.0, 10.0));
        drawTo(new CartesianPoint(10.0, 50.0));
        drawTo(new CartesianPoint(50.0, 50.0));
        moveTo(new CartesianPoint(20.0, 20.0));
        drawTo(new CartesianPoint(30.0, 20.0));
        
  6. Given a low address of 500 and a high address of 600, and coordinates of (0.0,0.0) at the low end and (50.0,50.0) at the high end, geocode address 560.
  7. Complete the two adjustFor() methods in the following RectangularHull class:
    /**
     * The smallest rectangle containing a set of Point objects (represented
     * as two Point objects, one containing the minimal coordinates and
     * one containing the maximal coordinates).
     */
    public class RectangularHull
    {
        private Point max, min;
    
    
        /**
         * Explicit Value Constructor
         */
        public RectangularHull(Point min, Point max)
        {
           double[]          v;
           int               n;
           
           n = min.getDimension();
           v = new double[n];
    
           for (int i=0; i<n; i++) v[i] = min.getCoordinate(i);
           this.min = new Point(v);
    
           for (int i=0; i<n; i++) v[i] = max.getCoordinate(i);
           this.max = new Point(v);
        }
        
    
        /**
         * Adjust this RectangularHull (if necessary) 
         * so that it includes the given Point
         *
         * @param p   The new Point
         */
        public void adjustFor(Point p)
        {
    
    
    
    
    
    
    
    
    
        }
        
    
        
    
        /**
         * Adjust this RectangularHull (if necessary) 
         * so that it includes another RectangularHull
         *
         * @param other   The other RectangularHull
         */
        public void adjustFor(RectangularHull other)
        {
    
    
    
    
    
    
    
    
    
    
        }
        
    
    
    
        /**
         * Get the maximal Point (e.g., the upper right corner)
         *
         * @return   The maximal point
         */
        public Point getMax()
        {
           return max;
        }
    
    
        /**
         * Get the minimal Point (e.g., the lower left corner)
         *
         * @return   The minimal point
         */
        public Point getMin()
        {
           return min;
        }
    
    
    
        /**
         * Create a String representation of this RectangularHull
         *
         * @return  The String
         */
        public String toString()
        {
           return (min.toString()+"\t"+max.toString());       
        }
        
        
    }
        
  8. Write an interface named MapProjection that contains all of the appropriate methods, properly documented.
  9. Explain why, in addition to a map projection, you needed an affine transformation in PA3 and PA4. Specifically, what needed to be done in that affine transformation?
  10. Given the following implementation of the Soundex algorithm:
    public class Soundex
    {
     
        public static String toCode(String s)
        {
    	char       c;
    	char[]     code = {'0','0','0','0'};
    	char[]     chars, coded, noDups, noHW, noVowels, source;
    	int        i, index, n, start;
     
     
    	// Create a character array
    	chars = s.toUpperCase().toCharArray();
     
     
            // Remove non alphabetic characters
            source = new char[chars.length];        
            index = 0;
            for (i=0; i<chars.length; i++)
            {
               if ((chars[i] < 'A') || (chars[i] > 'Z'))
               {
                  // Remove
               }
               else
               {
                  source[index] = chars[i];
                  index++;
               }
            }
            
     
    	// Code the consonants
    	coded = new char[index];
    	for (i=0; <coded.length; i++) {
     
    	    c = source[i];
    	    if       ((c=='B') || (c=='P') || (c=='F') || 
                          (c=='V')                            )   coded[i]='1';
     
    	    else if  ((c=='C') || (c=='S') || (c=='K') || 
                          (c=='G') || (c=='J') || (c=='Q') || 
    		      (c=='X') || (c=='Z')                )   coded[i]='2';
     
    	    else if  ((c=='D') || (c=='T') )                  coded[i]='3';
     
    	    else if  ((c=='L'))                               coded[i]='4';
     
    	    else if  ((c=='M') || (c=='N') )                  coded[i]='5';
     
    	    else if  ((c=='R'))                               coded[i]='6';
                else                                              coded[i]=c;
                
    	}
     
     
            // Remove H and W  (except if the first letter)
            noHW    = new char[coded.length];
            noHW[0] = coded[0];
            index   = 1;
    	for (i=1; i<coded.length; i++)
            {
    	    if ((coded[i] == 'H') || (coded[i] == 'W'))
                {
                   // Remove
                }
                else
                {
    		noHW[index] = coded[i];
    		index++;
    	    }
    	}
            
     
    	// Remove duplicates
    	noDups    = new char[index];
            noDups[0] = noHW[0];
            index     = 1;        
    	for (i=1; i<noDups.length; i++)
            {
    	    if (noHW[i] == noDups[index-1])
                {
    		// Duplicate
    	    }
                else
                {
    		noDups[index] = noHW[i];
    		index++;
    	    }
    	}
     
     
    	// Remove the vowels (except if the first letter) and non-alphabetic
    	noVowels    = new char[index];
    	noVowels[0] = noDups[0];
    	index       = 1;
    	for (i=1; <noVowels.length; i++) {
     
               if ((noDups[i]=='A') || (noDups[i]=='E') || (noDups[i]=='I') ||
                   (noDups[i]=='O') || (noDups[i]=='U') || (noDups[i]=='Y')      )
                {
                   // Remove
                }
                else
                {
    		noVowels[index] = noDups[i];
    		index++;
    	    }
    	}
     
     
    	// Construct the final code
    	code[0] = source[0];
    	n = code.length;
    	if (index < n) n = index;
    	for (i=1; i<n; i++) code[i] = noVowels[i];
     
    	return new String(code);
        }
     
    }
          

    calculate the Soundex code for each of the following street names.

    Eberhard


    Lee


    Pfister


    Heimbach


Copyright 2025