PIXELBANKv9.1.0
Menu

Identify core points in the DBSCAN algorithm.

A point is a core point if it has at least min_pts neighbors (including itself) within distance epsilon.

Given data points, epsilon, and min_pts, return the indices of all core points (sorted).

Use Euclidean distance for proximity.

Example:

Input:
X = [[0, 0], [1, 0], [0, 1], [10, 10]]
epsilon = 1.5
min_pts = 3
Output:
[0, 1, 2]
Reasoning:
  • The algorithm starts by calculating the Euclidean distance between each point and every other point in the dataset, using the formula d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}.
  • For each point, it counts the number of neighbors (including itself) within the given distance epsilon of 1.5.
  • The points [0, 0], [1, 0], and [0, 1] all have at least min_pts (3) neighbors within the distance epsilon, since they are close to each other and themselves, thus qualifying as core points.
  • The point [10, 10] does not have at least min_pts (3) neighbors within the distance epsilon, so it is not a core point, resulting in the output [0, 1, 2] which are the indices of the core points.

Constraints:

  • X: 2D list of data points
  • epsilon: maximum distance for neighborhood
  • min_pts: minimum number of points in neighborhood (including self)
  • Return sorted list of core point indices
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.