The one-dimensional clustering aims to group real-values of an input array into identified number of
clusters. Some of the current algorithms, such as the k-means, need the number of clusters in advance,
and use a goal function based on minimizing the sum of squared Euclidean distances to the mean of
each group. This paper shows why this goal function is not efficient, even for one-dimensional case, then
proposes an O (n × log n) efficient algorithm for the one-dimensional clustering purposes. The proposed
algorithm can automatically detect the number of clusters. The performance of the proposed algorithm
is approved across several experiments. In addition, results of experiments show why the goal function
used in some current algorithms like the k-means is not suitable for the one-dimensional clustering.