  We consider the problem of online Min-cost Perfect Matching with Delays
(MPMD) recently introduced by Emek et al, (STOC 2016). This problem is defined
on an underlying $n$-point metric space. An adversary presents real-time
requests online at points of the metric space, and the algorithm is required to
match them, possibly after keeping them waiting for some time. The cost
incurred is the sum of the distances between matched pairs of points (the
connection cost), and the sum of the waiting times of the requests (the delay
cost). We present an algorithm with a competitive ratio of $O(\log n)$, which
improves the upper bound of $O(\log^2n+\log\Delta)$ of Emek et al, by removing
the dependence on $\Delta$, the aspect ratio of the metric space (which can be
unbounded as a function of $n$). The core of our algorithm is a deterministic
algorithm for MPMD on metrics induced by edge-weighted trees of height $h$,
whose cost is guaranteed to be at most $O(1)$ times the connection cost plus
$O(h)$ times the delay cost of every feasible solution. The reduction from MPMD
on arbitrary metrics to MPMD on trees is achieved using the result on embedding
$n$-point metric spaces into distributions over weighted hierarchically
separated trees of height $O(\log n)$, with distortion $O(\log n)$. We also
prove a lower bound of $\Omega(\sqrt{\log n})$ on the competitive ratio of any
randomized algorithm. This is the first lower bound which increases with $n$,
and is attained on the metric of $n$ equally spaced points on a line.
  The problem of Min-cost Bipartite Perfect Matching with Delays (MBPMD) is the
same as MPMD except that every request is either positive or negative, and
requests can be matched only if they have opposite polarity. We prove an upper
bound of $O(\log n)$ and a lower bound of $\Omega(\log^{1/3}n)$ on the
competitive ratio of MBPMD with a more involved analysis.
