Link to webpage: www.srcmake.co...
A matrix is a 2-dimensional array, and each element in the array is represented by a row position and a column position. However, having two keys to represent one element is inconvenient for certain algorithms, such as being able to create a hash map to represent each element in the matrix.
In this video, we go over a trick to encode the position (i,j) for an element into a single value. We go through a diagram together for the encoding and decoding formulas, and then we look at some C++ code that implements the encodePosition and decodeValue functions.
Twitter: / srcmake
Twitch: / srcmake
Discord: / discord
26 авг 2024