This file contains the exercises, hints, and solutions for Chapter 7 of the
Exercises 7.1
1. Is it possible to exchange numeric values of two variables, say, and ,
without using any extra storage?
4. Is the distribution-counting algorithm stable?
5. Design a one-line algorithm for sorting any array of size whose values
are distinct integers from 1 to
7. BThe following technique, known as virtual initialization,providesa
time-efficient way to initialize just some elements of a given array [0−
1] so that for each of its elements, we can say in constant time whether it
has been initialized and, if it has been, with which value. This is done
a. Sketch the state of arrays [07][07]and [07] after the three
assignments
b. In general, how can we check with this scheme whether []has been
initialized and, if it has been, with which value?
1