XOR Swap Algorithm

20 minutes before I got to work, I was tackling against a couple of Mexico City's traffic jams !! and then, I recalled a simple but pretty cool algorithm I used like 5 years ago to swap 2 different variables without using a temporary one. If you're new at programming, there exist a variety of such algorithms, more commonly referred as Sorting Algorithms, and most of them use a temporary variable in order to swap the values they have, so, if u want to optimize your c0de and n1nj4 skillz ;) take a look at this !..

This is the XOR Swap Algorithm, and instead I explain it... A picture is worth a thousand words ;) ...


As you can see, it's mathematically simple, and below you can see the c0de & screensh0t I took a few minutes before ...



Keep h4cking !!

Comentarios

  1. Y dices que soy re mamon :p jeje

    "20 minutes before I got to work, I was tackling against a couple of Mexico City's traffic jams !! and then..."

    aqui esta la aplicacion, tambien lo puse en qsort

    http://math.co.ro/C/quickandslowsort.c

    Nos vemos en vegas! :D

    ResponderEliminar

Publicar un comentario

Entradas populares