Introduction to the Design and Analysis of Algorithms 3rd Edition Levitin Solutions Manual download
Introduction to the Design and Analysis of Algorithms 3rd Edition Levitin Solutions Manual download
https://testbankdeal.com/product/introduction-to-the-design-and-
analysis-of-algorithms-3rd-edition-levitin-solutions-manual/
https://testbankdeal.com/product/introduction-to-algorithms-3rd-
edition-cormen-solutions-manual/
https://testbankdeal.com/product/introduction-to-algorithms-2nd-
edition-cormen-solutions-manual/
https://testbankdeal.com/product/analysis-synthesis-and-design-of-
chemical-processes-3rd-edition-turton-solutions-manual/
https://testbankdeal.com/product/taxation-of-business-entities-6th-
edition-spilker-solutions-manual/
Delmar's Administrative Medical Assisting 5th Edition
Lindh Test Bank
https://testbankdeal.com/product/delmars-administrative-medical-
assisting-5th-edition-lindh-test-bank/
https://testbankdeal.com/product/comptia-linux-guide-to-linux-
certification-4th-edition-eckert-test-bank/
https://testbankdeal.com/product/basic-practice-of-statistics-8th-
edition-moore-test-bank/
https://testbankdeal.com/product/fundamentals-of-investment-
management-10th-edition-hirt-solutions-manual/
https://testbankdeal.com/product/money-banking-and-financial-
markets-3rd-edition-cecchetti-test-bank/
Access to Health 13th Edition Donatelle Test Bank
https://testbankdeal.com/product/access-to-health-13th-edition-
donatelle-test-bank/
This file contains the exercises, hints, and solutions for Chapter 6 of the
book ”Introduction to the Design and Analysis of Algorithms,” 3rd edition, by
A. Levitin. The problems that might be challenging for at least some students
are marked by B; those that might be difficult for a majority of students are
marked by I
Exercises 6.1
1. Consider the problem of finding the distance between the two closest num-
bers in an array of numbers. (The distance between two numbers and
is computed as | − |.)
a. You are given telephone bills and checks sent to pay the bills
1
( ≥ ) Assuming that telephone numbers are written on the checks,
find out who failed to pay. (For simplicity, you may also assume that
only one check is written for a particular bill and that it covers the bill in
full.)
P P
3 3
P P
1 1
P P
6 6
P P
2 2
=⇒
P P
4 4
P P5
5
a. Does the problem always have a solution? Does it always have a unique
solution?
2
For example, the numbers 4, 6, 3, 1, 8 can be placed in the five boxes as
shown below:
1 8 3 4 6
x
Design an efficient algorithm for finding all the maximum points of a given
set of points in the Cartesian plane. What is the time efficiency class
of your algorithm?
3
Hints to Exercises 6.1
1. This problem is similar to one of the examples in this section.
2. a. Compare every element in one set with all the elements in the other.
b. In fact, you can use presorting in three different ways: sort elements of
just one of the sets, sort elements of each of the sets separately, and sort
elements of the two sets together.
3. a. How do we find the smallest and largest elements in a sorted list?
b. How would you solve this problem if the student information were
written on index cards? Better yet, think how somebody else, who has
never taken a course on algorithms but possesses a good dose of common
sense, would solve this problem.
6. a. Many problems of this kind have exceptions for one particular config-
uration of points. As to the question about a solution’s uniqueness, you
can get the answer by considering a few small “random” instances of the
problem.
4
Solutions to Exercises 6.1
1. a. Sort the array first and then scan it to find the smallest difference
between two successive elements [] and [ + 1] (0 ≤ ≤ − 2).
Note that the efficiency formula implies that it is more efficient to sort the
smaller one of the two input sets.
( log ) + ( log ) + ( + ) = ( log ) where = max{ }
5
increment by two. If sorting is done with an log algorithm, the total
running time will be in
3. a. Sort the list and return its first and last elements as the values of
the smallest and largest elements, respectively. Assuming the efficiency
of the sorting algorithm used is in ( log ) the time efficiency of the
entire algorithm will be in
4. Let be the smallest number of searches needed for the sort—binary search
algorithm to make fewer comparisons than searches by sequential search
(for average successful searches). Assuming that a sorting algorithm
makes about log comparisons on the average and using the formulas
for the average number of key comparisons for binary search (about log2 )
and sequential search (about 2), we get the following inequality
Substituting = 103 into the right-hand side yields min = 21; substitut-
ing = 106 yields min = 40
Note: For large values of we can simplify the last inequality by elimi-
nating the relatively insignificant term log2 from the denominator of the
right-hand side to obtain
log2
≥ or ≥ 2 log2
2
This inequality would yield the answers of 20 and 40 for = 103 and
= 106 respectively.
6
to be done with respect to their telephone numbers, say, in increasing or-
der.) Then do a merging-like scan of the two sorted lists by comparing the
telephone numbers and on the current bill and check, respectively:
if , add to the list of unpaid telephone numbers and increment
; if , increment ; if = increment both and Stop as
soon as one of the two lists becomes empty and append all the remain-
ing telephone numbers on the bill list, if any, to the list of the unpaid ones.
b. Initialize 50 state counters to zero. Scan the list of student records and,
for a current student record, increment the corresponding state counter.
The algorithm’s time efficiency will be in Θ(), which is superior to any
algorithm that uses presorting of student records by a comparison-based
algorithm.
6. a. The problem has a solution if and only if all the points don’t lie on the
same line. And, if a solution exists, it may not be unique.
b. Find the lowest point ∗ i.e., the one with the smallest coordi-
nate. in the set. (If there is a tie, take, say, the leftmost among them,
i.e., the one with the smallest coordinate.) For each of the other − 1
points, compute its angle in the polar coordinate system with the origin
at ∗ and sort the points in increasing order of these angles, breaking ties
in favor of a point closer to ∗ (Instead of the angles, you can use the
line slopes with respect to the horizontal line through ∗ .) Connect the
points in the order generated, adding the last segment to return to ∗ .
P P
3 3
P P
1 1
P P
6 6
P P
2 2
=⇒
P P
4 4
P P5
5
7
Finding the lowest point ∗ is in Θ() computing the angles (slopes) is
in Θ() sorting the points according to their angles can be done with a
( log ) algorithm. The efficiency of the entire algorithm is in ( log )
7. Assume first that = 0 Then [] + [] = 0 if and only if [] = −[]
i.e., these two elements have the same absolute value but opposite signs.
We can check for presence of such elements in a given array in several dif-
ferent ways. If all the elements are known to be distinct, we can simply
replace each element [] by its absolute value |[]| and solve the element
uniqueness problem for the array of the absolute values in ( log ) time
with the presorting based algorithm. If a given array can have equal ele-
ments, we can modify our approach as follows: We can sort the array in
nondecreasing order of their absolute values (e.g., -6, 3, -3, 1, 3 becomes
1, 3, -3, 3, -6), and then scan the array sorted in this fashion to check
whether it contains a consecutive pair of elements with the same absolute
value and opposite signs (e.g., 1, 3, -3, 3, -6 does). If such a pair of
elements exists, the algorithm returns yes, otherwise, it returns no.
8
9. Start by sorting the list in increasing order. Then repeat the following
− 1 times: If the first inequality sign is "", place the first (smallest)
number in the first box; otherwise, place there the last (largest) number.
After that, delete the number from the list and the box it was put in.
Finally, when just a single number remains, place it in the remaining box.
Note: The problem was posted on a Web page of The Math Circle at
www.themathcircle.org/researchproblems.php (accessed Oct. 4, 2010).
x
Let (̄ ̄) be a point outputted by the algorithm. This means that it has
a larger -coordinate than any point previously encountered by the right-
to-left scan, i.e., any point with a larger coordinate. Hence, none of
those points can dominate (̄ ̄) No any point to be encountered later in
the scan can dominate this point either: all of them have either a smaller
coordinate or the same -coordinate but a smaller -coordinate. Con-
versely, if a point is not outputted by the algorithm, it is dominated by
another point in the set and hence is not a maximum point.
9
only if they have the same signature. Sort the records in alphabetical or-
der of their signatures. Scan the list to identify contiguous subsequences,
of length greater than one, of records with the same signature.
10
Visit https://testbankdead.com
now to explore a rich
collection of testbank,
solution manual and enjoy
exciting offers!
Exercises 6.2
1. Solve the following system by Gaussian elimination.
1 + 2 + 3 = 2
21 + 2 + 3 = 3
1 − 2 + 33 = 8
11
8. The Gauss-Jordan elimination method differs from Gaussian elimina-
tion in that the elements above the main diagonal of the coefficient matrix
are made zero at the same time and by the same use of a pivot row as the
elements below the main diagonal.
c.B In general, how many multiplications are made by this method while
solving a system of equations in unknowns? How does this compare
with the number of multiplications made by the Gaussian elimination
method in both its elimination and its back-substitution stages?
9. A system = of linear equations in unknowns has a unique solution
if and only if det 6= 0 Is it a good idea to check this condition before
applying Gaussian elimination to the system?
10. a. Apply Cramer’s rule to solve the system of Problem 1 of these exercises.
12
Hints to Exercises 6.2
1. Trace the algorithm as we did in solving another system in the section.
2. a. Use the Gaussian elimination results as explained in the text.
13
10. a. Apply Cramer’s rule to the system given.
b. How many distinct determinants are there in the Cramer’s rule for-
mulas?
11. a. If is the number of times the panel in the th row and th column
needs to be toggled in a solution, what can be said about ? After you
answer this question, show that the binary matrix representing an initial
state of the board can be represented as a linear combination (in modulo
2 arithmetic) of 2 binary matrices each representing the affect of toggling
an individual panel.
14
Solutions to Exercises 6.2
1. a. Solve the following system by Gaussian elimination
1 + 2 + 3 = 2
21 + 2 + 3 = 3
1 − 2 + 33 = 8
⎡ ⎤
1 1 1 2
⎣ 2 1 1 3 ⎦ row 2 - 21 row 1
1 −1 3 8 row 3 - 11 row 1
⎡ ⎤
1 1 1 2
⎣ 0 −1 −1 −1 ⎦
−2
0 −2 2 6 row 3 - −1 row 2
⎡ ⎤
1 1 1 2
⎣ 0 −1 −1 −1 ⎦
0 0 4 8
2. a. Repeating the elimination stage (or using its results obtained in Prob-
lem 1), we get the following matrices and :
⎡ ⎤ ⎡ ⎤
1 0 0 1 1 1
= ⎣ 2 1 0 ⎦ = ⎣ 0 −1 −1 ⎦
1 2 1 0 0 4
Its solution is
15
Random documents with unrelated
content Scribd suggests to you:
formes particulières, les provincialismes se détacheront d'eux-
mêmes.
Appelons, si vous voulez, ces provincialismes des dialectes; le
nom n'y fait rien, pourvu qu'on s'entende bien sur la chose signifiée.
Ces dialectes me paraissent pouvoir faire l'objet d'un travail spécial
secondaire, dont je n'ai pas cru devoir compliquer celui-ci.
TROISIÈME PARTIE.
APPLICATIONS ET CONSÉQUENCES.
AVERTISSEMENT.
Dans les deux premières parties, nous avons tâché d'établir une
théorie; dans la troisième, nous allons chercher à la vérifier par des
applications, à justifier les principes par les conséquences. Sans
cette troisième partie, on ne verrait guère de quelle utilité peuvent
être les deux autres. La question de l'orthographe et de la
prononciation primitives du français pourrait ne sembler qu'une
curiosité philologique, bonne à renfermer dans le cabinet d'un
littérateur, à défrayer quelques discussions entre savants, et rien au
delà.
Il n'en va pas ainsi, au moins dans mon opinion. Cette étude doit
servir à raffermir, en les éclairant, les bases de notre idiome; à
expliquer en beaucoup de points notre langue moderne, et à
protéger sa marche dans l'avenir. La comparaison de ce qui a été
avec ce qui est, conduira plus sûrement vers ce qui doit être. En
reconnaissant nos fautes et les causes de nos fautes, nous nous
trouvons à même d'en réparer encore une partie, et nous apprenons
à nous détourner d'écueils désormais connus.
J'indique ici les résultats, non de ce que j'ai fait, mais de ce que
pourront faire de plus habiles, en pratiquant la même voie. Je me
borne à réclamer l'honneur d'y avoir hasardé le premier pas; de plus
forts iront plus loin.
La lecture de cette troisième partie dédommagera quelque peu,
je l'espère, ceux qui auront eu la patience de me suivre jusque-là. Il
m'eût été facile de réunir un nombre bien plus considérable
d'observations; car étant donnée la théorie, l'on trouve à chaque pas
à faire une expérience. J'en laisserai le plaisir ou l'ennui à ceux qui le
voudront prendre; il me suffit de montrer de quelle façon l'on peut y
procéder. Si parmi ces remarques détachées il s'en est glissé
quelqu'une sans rapport immédiat avec les principes que j'ai tâché
d'établir, on voudra bien me la pardonner. Elle intéresse toujours la
langue par quelque côté; à ce titre, si elle est juste, elle est utile, et
je ne sors pas de mon sujet. D'ailleurs, je n'ai pas pour dernier but
les syllabes et la grammaire, mais la littérature. C'est pour arriver
plus sûrement à ce terme que j'ai pris un point de départ si éloigné.
Tout ce qui peut, en faisant connaître la littérature du moyen âge,
donner l'envie avec les moyens de l'étudier, rentre donc dans mon
plan, et je pense qu'après avoir lu tant de détails élémentaires, on
ne me reprochera pas ces courtes excursions dans une région moins
aride et plus élevée.
CHAPITRE PREMIER.
De l'articulation des consonnes chez les modernes.—
Conséquences du système actuel: vers faux, rimes fausses,
hiatus.
Nous en sommes à appeler rime riche une rime qui ne rime pas;
l'accouplement d'une rime masculine avec une féminine:
Et cinq cent mille francs avec elle obtenus
La firent à ses yeux plus belle que Vénusse.
Est-ce là des hiatus, oui ou non? Vous ne verrez chez nous rien
de pareil. Vous me reprochez va il, a on, que nous prononcions vat il,
at on; c'est justement comme lorsque vous niez l'hiatus de huissier
ayez, en vous armant de l'r finale de huissier, laquelle ne se
prononce pas. Vous êtes dans les deux cas dupes de votre vue au
préjudice de votre ouïe. Vos vers modernes semblent fabriqués pour
des sourds qui auraient de bons yeux; les nôtres charmeront encore
les aveugles qui conservent de bonnes oreilles. Si Homère pouvait
juger notre débat, à qui pensez-vous qu'il donnât gain de cause?
Ce que j'en dis n'est pas pour nous défendre de tout hiatus. A
Dieu ne plaise, ni à Apollon son serviteur! Il y a des hiatus très-doux
et très-musicaux. Nation, Danaé, Simoïs, violence, sont délicieux à
l'oreille; nous n'avons pas été si sots que de les proscrire. Vous me
direz sans doute que ces hiatus ont lieu dans le corps d'un seul mot,
et non pas d'un mot à un autre. Belle distinction, et profonde! Est-ce
que l'intervalle qui sépare les mots sur le papier subsiste pour
l'oreille? Écoutez parler une langue à vous inconnue, ou peu connue;
est-ce que vous surprenez où finit un mot et où un autre
commence? Toute une phrase ne glisse-t-elle pas à l'oreille comme
un seul et unique mot? Qu'est-ce donc que cette distinction
artificielle? Faites-moi la grâce de m'expliquer la différence entre
l'impersonnel il y a et le nom de la vestale Ilia; comment l'un forme
un insupportable hiatus, et l'autre une charmante harmonie. Cela
paraît très-raffiné! Grâce à ce raffinement et à l'absolutisme d'une
règle absurde, votre poëte est dispensé de montrer du tact dans le
choix de ses hiatus, admettant celui-ci et repoussant celui-là. Non;
tout hiatus, quel qu'il soit, est banni. Votre loi brutale ne souffre
point d'exceptions: aussi êtes-vous arrivés à ce beau résultat, que
vos vers fourmillent d'hiatus, et légitimes, qui pis est!
Jugez la valeur relative de nos principes par la différence des
effets: nous, avec des voyelles en contact, nous savions éviter
l'hiatus à l'aide des consonnes intercalaires; et vous, vous trouvez
moyen d'avoir des hiatus entre deux voyelles séparées par une
consonne écrite. Il faut avouer que le progrès est admirable! Nous
sommes en effet les barbares, et vous êtes les gens civilisés, les
grands artistes!
A ce discours du ressuscité, je ne vois pas trop ce qu'il y aurait à
répondre.
CHAPITRE II.
Du patois des paysans de comédie.
[82] Les éditeurs ont mal à propos écrit averiumes, prenant sur
eux cette distinction, qui n'existe dans aucun manuscrit, de l'u voyelle
et de l'u consonne. La mesure démontre que c'est ici l'u voyelle qu'il
faut prendre. En mettant averiumes, le vers est faux.
Ferront, par syncope pour feriront; les Français sont bons, dit
Roland; ils frapperont en braves.
Mais cette troisième personne aujourd'hui ne se termine plus en
ont, excepté au futur; aux autres temps l'e muet a remplacé l'o; ils
aiment, ils appellent, etc. Il y avait jadis plus d'uniformité:
PIERROT.
«Allons, Lucas, ç'ai-je dit, tu vois bian qu'ils nous appelont!… Que
d'histoires et d'engingorniaux boutont ces messieux-là!… Jarni, v'là
où l'on voit les gens qui aimont!…»
(Don Juan, act. II, sc. 1.)
Je retrouve également cette forme dans la traduction du livre de
Job, faite au commencement du XII e siècle:—«Li Caldeu… envaïrent
les chamoz, si les enmenont.»
(P. 501.)
Un duc i ot, qu'apelont Fauseron.
(La Desconfite de Roncevaux, introd. du
Roland, p. 55.)
Vous avez été averti que oi sonnait jadis oué; que les Français
avaient été successivement les Fransoués, puis les Francés; c'est
pourquoi il est bon, aujourd'hui qu'ils sont devenus les Français,
d'écrire leur nom par ai, en dépit des gens qui, pour ce fait,
vilipendent encore tous les jours monsieur de Voltaire, comme ils
l'appellent très-malignement.
Moi, foi, roi, étaient donc prononcés moué, foué, roué, en un
monosyllabe très-bref.
Le son ouvert de cet oi est un des griefs de Henri Estienne contre
les seigneurs de son temps, qui prononçaient troas moas, je voas.
Pierrot avait pris d'eux cette mauvaise prononciation:
CHARLOTTE.
«Va, va, Piarrot, ne te mets point en peine: si je sis madame, je
te ferai gagner queuque chose, et tu apporteras du beurre et du
fromage cheux nous.
PIERROT.
«Ventreguienne! je gny en porterai jamais, quand tu m'en
payerois deux fouas autant!» (Don Juan.)
Mais pour cette fouas il faut pardonner à Pierrot, car sa cause est
la nôtre; et nous ne saurions le condamner sans nous enfermer dans
le même arrêt.
Que reste-t-il encore? Certaines syncopes hardies.
CHARLOTTE.
«Je vous dis qu'ous vous teigniez!… Parce qu'ous êtes
monsieu!…»
C'est encore un emprunt au langage de la cour de François I er,
qui disait sans façon, a'vous, sa'vous, pour avez-vous, savez-vous. La
reine de Navarre ne s'est point fait scrupule d'user de cette syncope
dans ses poésies mystiques, et Théodore de Bèze l'autorise par une
règle expresse. (Voy. p. 225 et 226.) Ayant pour elle ces graves
autorités, Charlotte ne peut être inquiétée pour son style.
Ce n'est pas la peine de s'arrêter à ces formes, je lairai, je donrai,
pour je laisserai, je donnerai:
Compère Guilleri,
Te lairras-tu mouri?
(Chanson populaire.)
«Les valets n'aiment pas les bijoux; ils préfèrent l'argent sec. Hé
bien! je lui donnerai quinze sous.»
Sur ce futur syncopé, voyez pages 210-213.
Ces mauvaises liaisons, on z'a, on z'entra, sont également
expliquées au chapitre des consonnes euphoniques:—«Uns entrad
n'ad gaires el paveillom le rei, pur li ocire.» (Rois, p. 104)—«On
entra naguère au pavillon du roi, pour le tuer.»
testbankdeal.com