From: Martin Mares Date: Tue, 19 Feb 2008 12:38:19 +0000 (+0100) Subject: Start with ranks. X-Git-Tag: printed~241 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8ef36d9c3827f4f9c4ad864f93e68f35e7223170;p=saga.git Start with ranks. --- diff --git a/notation.tex b/notation.tex index 5517660..a9f1fa2 100644 --- a/notation.tex +++ b/notation.tex @@ -57,6 +57,8 @@ \n{$\bxor$}{bitwise non-equivalence: $(x\bxor y)[i]=1$ iff $x[i]\ne y[i]$} \n{$x \shl n$}{bitwise shift of~$x$ by $n$~positions to the left: $x\shl n = x\cdot 2^n$} \n{$x \shr n$}{bitwise shift of~$x$ by $n$~positions to the right: $x\shr n = \lfloor x/2^n \rfloor$} +\n{$R_{C,\prec}(x)$}{the rank of~$x$ in a~set~$C$ ordered by~$\prec$ \[rankdef]} +\n{$R^{-1}_{C,\prec}(i)$}{the unrank of~$i$: the $i$-th smallest element of a~set~$C$ ordered by~$\prec$ \[rankdef]} } %-------------------------------------------------------------------------------- diff --git a/ram.tex b/ram.tex index f576e83..2442df3 100644 --- a/ram.tex +++ b/ram.tex @@ -3,6 +3,7 @@ \fi \chapter{Fine Details of Computation} +\id{ramchap} \section{Models and machines} @@ -342,7 +343,7 @@ and Willard. It will also form a~basis for the rest of this chapter. %-------------------------------------------------------------------------------- -\section{Bits and vectors} +\section{Bits and vectors}\id{bitsect} In this rather technical section, we will show how the RAM can be used as a~vector computer to operate in parallel on multiple elements, as long as these elements diff --git a/rank.tex b/rank.tex index a0823ea..365fa94 100644 --- a/rank.tex +++ b/rank.tex @@ -4,7 +4,40 @@ \chapter{Ranking Combinatorial Structures} -\section{Ranking of permutations} +\section{Ranking and unranking} + +The techniques for building efficient data structures on the RAM described +in Chapter~\ref{ramchap} can be also used for a~variety of problems related +to ranking of combinatorial structures. Generally, the problems are stated +in the following way: + +\defn\id{rankdef}% +Let~$C$ be a~set of objects and~$\prec$ a~linear order on~$C$. The \df{rank} +$R_{C,\prec}(x)$ of an~element $x\in C$ is the number of elements $y\in C$ such that $y\prec x$. +When~$\prec$ is defined on some superset of~$C$, we naturally extend the rank +to elements outside~$C$. +We will call the function $R_{C,\prec}$ the \df{ranking function} for $C$ and~$\prec$ +and its inverse $R^{-1}_{C,\prec}$ the \df{unranking function}. When the set +and the order are clear from the context, we will use just~$R(x)$ and $R^{-1}(x)$. + +\example +Let us consider the set $C_k=\{\0,\1\}^k$ of all binary strings of length~$k$ ordered +lexicographically. Then $R^{-1}(i)$ is the $i$-th smallest element of this set, that +is the number~$i$ written in binary and padded to~$k$ digits (i.e., $\(i)_k$ in the +notation of Section~\ref{bitsect}). Obviously, $R(x)$ is the integer whose binary +representation is~$x$. +\FIXME{Uses of ranks.} + +\para +In this chapter, we will investigate how to compute the ranking and unranking +functions on different sets. Usually, we will make use of the fact that the ranks +(and hence the input and output of our algorithm) are large numbers, so we can +use the integers of a~similar magnitude to represent non-trivial data structures. +This will allow us to design efficient algorithms on the RAM. + +\FIXME{In the whole chapter, assume RAM.} + +\section{Ranking of permutations} \endpart