courses/coursera-sandiego-algorithms/algorithmic-toolbox/assignment003/closest/closest.cpp
double minimal_distance_split(vector<int>& order, vector<int>& xs, vector<int>& ys, int depth)
{
  double distance = std::numeric_limits<double>::max();
  for(int i = 0; i < order.size();++i)
  {
    for(int j = i+1; j < std::min(i+8,(int)order.size());++j)
    {
        auto d = dist(std::make_tuple(xs[order[i]],ys[order[i]]),std::make_tuple(xs[order[j]],ys[order[j]]));
        // tab(depth) << "[" << i << "," << j << "] = <("<< xs[order[i]] <<"," << ys[order[i]] << "),(" << xs[order[j]] << "," << ys[order[j]] << ")> = " << d << std::endl;
        if(distance > d)
        {
          distance = d;
        }
    }
  }
  return distance;
}
//To understand why we only need to go 8 more points in this list
//see the algo_proff.odg on the same folder as this file.
To understand why we only need to go 8 more points in this list
see the algo_proff.odg on the same folder as this file.
To understand why we only need to go 8 more points in this list see the algo_proff . odg on the same folder as this file .
double minimal_distance_split(vector<int>& order, vector<int>& xs, vector<int>& ys, int depth)
{
  double distance = std::numeric_limits<double>::max();
  for(int i = 0; i < order.size();++i)
  {
    for(int j = i+1; j < std::min(i+8,(int)order.size());++j)
    {
        auto d = dist(std::make_tuple(xs[order[i]],ys[order[i]]),std::make_tuple(xs[order[j]],ys[order[j]]));
        if(distance > d)
        {
          distance = d;
        }
    }
  }
  return distance;
}
double minimal_distance_split ( vector < int > & order , vector < int > & xs , vector < int > & ys , int depth ) { double distance = std :: numeric_limits < double > :: max ( ) ; for ( int i = 0 ; i < order . size ( ) ; ++ i ) { for ( int j = i + 1 ; j < std :: min ( i + 8 , ( int ) order . size ( ) ) ; ++ j ) { auto d = dist ( std :: make_tuple ( xs [ order [ i ] ] , ys [ order [ i ] ] ) , std :: make_tuple ( xs [ order [ j ] ] , ys [ order [ j ] ] ) ) ; if ( distance > d ) { distance = d ; } } } return distance ; }
To understand why we only need to go 8 more points in this list
see the algo_proff.odg on the same folder as this file.
To understand why we only need to go 8 more points in this list see the algo_proff . odg on the same folder as this file .
// tab(depth) << "[" << i << "," << j << "] = <("<< xs[order[i]] <<"," << ys[order[i]] << "),(" << xs[order[j]] << "," << ys[order[j]] << ")> = " << d << std::endl;