There are many different distances but today we will be talking about Manhattan distance and Euclidean distance. Mahattan distance is based on the gridlike street geography of the New York borough of Mahattan.
For 2D : Manhattan Distance's formula is abs(x1-x2)+abs(y1-y2). Euclidean distance's formula is sqrt((x1-x2)^2+(y1-y2)^2). This is equivalent to the Pythagorean theorem.
This chapter is an easy, short and fundamental chapter. (in fact the whole math chapter is easy, short and fundamental)
In the picture, in red, blue and yellow, you have Manhattan distance. And in green is the Euclidean distance.
Subscribe to:
Post Comments (Atom)
std::next_permutation(arr.begin(),arr.end());
What is next_permutation(a.begin(),a.end()) ? Next permutation is like what its name says, finds the next permutation of a and assigns ...
-
Usage of __int128_t: supports really big intermediate numbers, from -2^128 + 1 to 2^128 - 1 it has 128 bits Usage of __float128 : ...
-
Here are some extensions that I have found. Some of them are more useful than others. indexed set power(x,y) rope indexed set is j...
-
Method 1 : A noob's way : #include <iostream> using namespace std; int main(){ int nb,a; cin >>...
No comments:
Post a Comment