We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b60de8d commit 8a68809Copy full SHA for 8a68809
Python/machine_learning/knn.py
@@ -21,6 +21,16 @@
21
4. Use majority voting to determine the predicted class.
22
5. Return the predicted label.
23
24
+ Time Complexity (per prediction):
25
+ 1 Distance calculation → O(n * d)
26
+ 2 Sorting distances → O(n log n)
27
+ 3 Selecting k nearest points → O(k)
28
+ 4 Majority voting (Counter) → O(k)
29
+ 🔹 Overall → O(n * d + n log n)
30
+
31
+ Space Complexity:
32
+ O(n * d) → to store all distances and intermediate computations
33
34
Contributor:
35
---------------------
36
💻 Contributed by: **Lakhinana Chaturvedi Kashyap**
0 commit comments