Exam 1

  1. Question

    Given two points p=(2,4)p = (2, 4) and q=(4,4)q = (4, 4) 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 (d∞d_\infty).


    1. d1(p,q)=∑i|pi−qi|=|2−4|+|4−4|=2d_1(p, q) = \sum_i |p_i - q_i| = |2 - 4| + |4 - 4| = 2.
    2. d2(p,q)=∑i(pi−qi)2=(2−4)2+(4−4)2=2d_2(p, q) = \sqrt{\sum_i (p_i - q_i)^2} = \sqrt{(2 - 4)^2 + (4 - 4)^2} = 2.
    3. d∞(p,q)=maxi|pi−qi|=max(|2−4|,|4−4|)=2d_\infty(p, q) = \max_i |p_i - q_i| = \max(|2 - 4|, |4 - 4|) = 2.