This multi-part question evaluates understanding of K-means clustering, interval-merging algorithms, and frequency-based top-k retrieval, assessing competencies in unsupervised learning concepts, algorithmic problem solving, data structures, and complexity analysis.
Given:
X
with shape
(n_samples, d)
.
k
(number of clusters).
Explain (or write high-level pseudocode for) the K-means algorithm such that:
Given a list of closed intervals intervals, where each interval is [start, end] and start <= end, merge all overlapping intervals and return the merged list.
Input: intervals: List[List[int]]
Output: merged intervals in any order (or sorted by start), with no overlaps.
Given an integer array nums and an integer k, return the k values that occur most frequently.
Input: nums: List[int], k: int
Output: List[int] containing k elements.
1 <= n <= 2e5
1 <= k <= number of distinct values in nums