paint-brush
Reversing an n-bit number in O(log n) timeby@ehudt
1,729 reads
1,729 reads

Reversing an n-bit number in O(log n) time

by Ehud Tamir3mDecember 24th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Last week, while writing my <a href="https://medium.com/p/537cc8bb9f52" target="_blank">previous post</a>, I came across an interesting algorithm for reversing an integer. For example, it takes <code class="markup--code markup--p-code">10100011</code> and transform it into <code class="markup--code markup--p-code">11000101</code>. What’s cool about this algorithm, is that it does it in O(log n) iterations. This is the code:

Company Mentioned

Mention Thumbnail
featured image - Reversing an n-bit number in O(log n) time
Ehud Tamir HackerNoon profile picture
Ehud Tamir

Ehud Tamir

@ehudt

L O A D I N G
. . . comments & more!

About Author

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite