public static Object[] discreetKNNClassify2(Point coord,ArrayList<Point> positiveCoords ,ArrayList<Point> negativeCoords, int k)
    {

	// Stores the nearest neighbours.
	Vector<Neighbour> neighbours = new Vector<Neighbour>();

	// Calculate distances to neighbours
	for(int i = 0; i < positiveCoords.size();i++)
	{
	    double distance = Common.distance(coord.getX(),coord.getY(),positiveCoords.get(i).getX(),positiveCoords.get(i).getY());
	    neighbours.add(new Neighbour(distance, Constants.PULSAR));
	}

	for(int i = 0; i < negativeCoords.size();i++)
	{
	    double distance = Common.distance(coord.getX(),coord.getY(),negativeCoords.get(i).getX(),negativeCoords.get(i).getY());
	    neighbours.add(new Neighbour(distance, Constants.RFI));
	}

	// Sort the neighbours such that element zero has the smallest distance.
	Collections.sort(neighbours);

	if(k > neighbours.size())
	{
	    System.out.println("K larger than number of neihbours. K "+ k + " Neihbours"+ neighbours.size());
	    return null;
	}

	System.out.println("K value:"+ k);

	//for(int i =0; i < neighbours.size();i++)
	//{
	//    System.out.println("Neighbour: "+ i + " "+ neighbours.elementAt(i).toString());
	//} // Debugging purposes

	int k_count =0;
	Vector<Neighbour> k_nearest_neighbours = new Vector<Neighbour>();
	Vector<NearestNeighbour> knn = new Vector<NearestNeighbour>();

	NearestNeighbour currentNeighbour = null;

	for(int i =0; i < neighbours.size();i++)
	{
	    // if the distance measure found is unique
	    if(!k_nearest_neighbours.contains(neighbours.elementAt(i)))
	    {
		// increment count of K unique neighbours found.
		k_count++;

		if(currentNeighbour != null)
		{
		    knn.add(currentNeighbour);
		    currentNeighbour = null;
		}

		if(k_count > k)// if we have more than K unique examples found
		    break;// break the loop


		currentNeighbour = new NearestNeighbour(neighbours.elementAt(i).getDistance(),k_count);
		currentNeighbour.processNeighbour(neighbours.elementAt(i));

		// else add the new unique neighbour
		k_nearest_neighbours.add(neighbours.elementAt(i));		
	    }
	    else // the neighbour is not unique, but repeated
	    {
		currentNeighbour.processNeighbour(neighbours.elementAt(i));
		k_nearest_neighbours.add(neighbours.elementAt(i));// still keep the neighbour for majority voting 
	    }

	}

	if(currentNeighbour != null )
	{
	    knn.add(currentNeighbour);
	    currentNeighbour = null;
	}

	for(int i =0; i < knn.size();i++)
	    System.out.println("Initial KNN:"+ knn.get(i));
	
	int neighbours_chosen = 0;
	k_nearest_neighbours.clear();
	k_nearest_neighbours = null;
	Vector<NearestNeighbour> final_knn = new Vector<NearestNeighbour>();
	
	for(int i = 0 ; i < knn.size();i++)
	{
	    System.out.println("Neighbours Chosen:" +neighbours_chosen + " k:"+k);
	    if (neighbours_chosen == k)
	    {
		System.out.println("Loop Broken");
		break;
	    }
	    
	    if((neighbours_chosen + knn.get(i).getFrequency()) < k )
	    {
		System.out.println("Neighbours Chosen (" +neighbours_chosen + ") + freq("+knn.get(i).getFrequency()+") < "+k);
		if(knn.get(i).getFrequency()==1)
		{
		    final_knn.add(knn.get(i).drawNeighbourNoReplacement());
		    neighbours_chosen++;
		}
		else
		{
		    for(int j=0; j < knn.get(i).getFrequency();j++)
			final_knn.add(knn.get(i).drawNeighbourNoReplacement());
		    
		    neighbours_chosen += knn.get(i).getFrequency();
		}
	    }
	    else if((neighbours_chosen + knn.get(i).getFrequency()) > k )
	    {
		System.out.println("Neighbours Chosen (" +neighbours_chosen + ") + freq("+knn.get(i).getFrequency()+") > "+k);
		int diff = k - neighbours_chosen;
		
		if(diff < knn.get(i).getFrequency())
		    for(int j=0; j < diff;j++)
			final_knn.add(knn.get(i).drawNeighbourNoReplacement());
		
		 neighbours_chosen += diff;
	    }
	    else if((neighbours_chosen + knn.get(i).getFrequency()) == k )
	    {
		System.out.println("Neighbours Chosen (" +neighbours_chosen + ") + freq("+knn.get(i).getFrequency()+") == "+k);
		for(int j=0; j < knn.get(i).getFrequency();j++)
			final_knn.add(knn.get(i).drawNeighbourNoReplacement());
		    
		  neighbours_chosen += knn.get(i).getFrequency();
	    }
	}

	System.out.println("Final KNN size():" +final_knn.size());
	for(int i =0; i < final_knn.size();i++)
	    System.out.println("Post KNN:" +final_knn.get(i));


	// do some explicit house keeping
	// for no other reason other than it makes me feel better :D
	neighbours.clear();
	neighbours = null;

	String classification = "";

	int tieBreakingParameter = 1;
	if(tieBreakingParameter== 0)
	    classification = NearestNeighbour.getClassificationBTN(final_knn);
	else if (tieBreakingParameter == 1)
	    classification = NearestNeighbour.getClassificationBTR(final_knn);

	System.out.println("Classification:"+classification);
	return new Object[]{classification,coord};
    }