Exam 1

  1. Question

    Given two points p=(3,4)p = (3, 4) and q=(5,2)q = (5, 2) in a Cartesian coordinate system:


    1. What is the Manhattan distance d1(p,q)d_1(p, q)?
    2. What is the Euclidean distance d2(p,q)d_2(p, q)?
    3. What is the maximum distance d(p,q)d_\infty(p, q)?

    Solution

    The distances are visualized below in green (d1d_1), red (d2d_2), and blue (dd_\infty).


    1. d1(p,q)=i|piqi|=|35|+|42|=4d_1(p, q) = \sum_i |p_i - q_i| = |3 - 5| + |4 - 2| = 4.
    2. d2(p,q)=i(piqi)2=(35)2+(42)2=2.828d_2(p, q) = \sqrt{\sum_i (p_i - q_i)^2} = \sqrt{(3 - 5)^2 + (4 - 2)^2} = 2.828.
    3. d(p,q)=maxi|piqi|=max(|35|,|42|)=2d_\infty(p, q) = \max_i |p_i - q_i| = \max(|3 - 5|, |4 - 2|) = 2.