MetaCart Sign in to MyCiteSeerX

Include Citations | Advanced Search | Help

Disambiguated Search | Include Citations | Advanced Search | Help

Using de Bruijn Sequences to Index a 1 in a Computer Word (1998) [2 citations — 1 self]

by Charles E. Leiserson ,  Harald Prokop ,  Keith H. Randall
Add To MetaCart

Abstract:

Some computers provide an instruction to find the index of a 1 in a computer word, but many do not. This paper provides a fast and novel algorithm based on de Bruijn sequences to solve this problem. The algorithm involves little more than an integer multiply and a lookup in a small table. We compare the performance of our algorithm with other popular strategies that use table lookups or floating-point conversion. 1 Introduction Many applications that use one-word bit vectors require the ability to find the binary index of a 1 in a word. For example, some computers set a bit in an interrupt mask when an interrupt occurs, and the interrupt handler must determine which bit is set in order to properly vector the interrupt. Many chess programs represent the pieces of a given type as a 64-bit word, each bit of which indicates the presence or absence of the piece type on a particular square of the chessboard [5]. To determine which square a piece occupies as a row/column index, the inde...

Citations

6121 Introduction to Algorithms – Cormen, Leiserson, et al. - 2001
142 K.H.: The implementation of the Cilk-5 multithreaded language – Frigo, Leiserson, et al. - 1998
3 Creating a Chess Player – Frey, Atkin - 1979
1 de Bruijn. A combinatorial problem – Nicolaas - 1946
1 Pentium Pro Family Developer's – Corp - 1995