Anant has gifted Audemars Piguet only to people who have the money to buy it on their own. And Haldiram bhujia to people who have the money to buy it on their own.
Rest of the world suddenly discovering Tauism
while Teen Taaliya TT Staff be like
हम इस लड़के को जानते है बहुत तगड़ा मारता है।
और झारखंड तो है ही। 😄
@kamleshksingh@kuldeepmishra
Understand that you’ve limited time.
Understand your limitations.
You can’t be doing dev, learning devOps, doing CP, giving contests, attending hackathons, applying for jobs/internships, learning ML, building projects, making that portfolio and trying to stay fit all at once.
Also understand that you do have time. You can do all of them in a subjectively decent manner in a span of 4-5 years. But not at once. It’s not possible, and it’s counterproductive
Don’t compare yourself with 10 different people and feel inferior 10 times a day.
I am pretty good at ML, someone is in backend, someone in CP and so on. Your comparison should be with yourself and your goal should be to become like 1 of those 10 people. Not all 10 of them combined.
Tech or not tech, living life while making a good career requires setting priorities and knowing what’s possible and what’s not.
Now that doesn’t mean don’t push yourself but to get the best in life you’ve to have a direction.
If you’re into DSA or ML or data science this post is for you. This question might be asked in ML interviews as well.
So recently I held a poll on time complexity of the famous KNN algorithm.
Frankly all of the people got it wrong.
Straight answer for people who don’t wanna spend time, the time complexity (best) of a KNN algorithm for D dimension space and N points is O(ND + (K-N)*log(K)).
But how?
Let’s revisit KNN again shall we?
1. You load the data into memory
2. For a new point, say P you calculate Euclidean distance of this point with every other point. Since data point is D dimension that calculation for 1 point is O(D), for N points its O(ND). Put all these distances into a list. Call it distance list
3. Now you have to take the top K closest points from the dataset wrt the distance. A naive way would be, you sort distance list you calculated in step 2 and take first K points, that would be O(Nlog(N)) since there are N distances.
4. Another way could be, you iterate K times and each time you get the point with minimum distance and put it in a separate list and remove it from distance list. This would get you O(KN)
But can’t we do better? Of course we can
Remember this problem is similar to taking top K elements from an array, just that now you’ve points and their distance.
So, consider this. Make a max heap of K nodes from the first K points from the distance list.
Time complexity to make a heap? O(length), here O(K).
Now for remaining (N-K) points simply compared its distance with node’s. If new points distance is less than node’s distance, replace the node with this new element and call heapify. Else don’t do anything.
Time complexity of this? (N-K)log(K)
Total time complexity? O(ND+(N-K)logK+K)
Since K is very less generally you can ignore the last K and the complexity becomes O(ND + (K-N)*log(K)).
Do share if you found this insightful
#SoftwareEngineering #MachineLearning #DataScience #timecomplexity