[Algorithm Trick] Encoding Matrix Position Into A Single Value

Published: 06 March 2020
on channel: srcmake
240
5

Link to webpage: https://www.srcmake.com/home/encode-m...

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  


On this page of the site you can watch the video online [Algorithm Trick] Encoding Matrix Position Into A Single Value with a duration of hours minute second in good quality, which was uploaded by the user srcmake 06 March 2020, share the link with friends and acquaintances, this video has already been watched 240 times on youtube and it was liked by 5 viewers. Enjoy your viewing!