Complete Download of Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Edition : 013284737X Full Chapters in PDF DOCX
Complete Download of Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Edition : 013284737X Full Chapters in PDF DOCX
com
https://testbankmall.com/product/solution-manual-for-data-
structures-and-algorithm-analysis-in-c-4-e-4th-
edition-013284737x/
OR CLICK HERE
DOWLOAD NOW
Visit now to discover comprehensive Test Banks for All Subjects at testbankmall.com
Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...
https://testbankmall.com/product/solution-manual-for-data-structures-
and-algorithm-analysis-in-c-2-e-2nd-edition-0201498405/
testbankmall.com
https://testbankmall.com/product/solution-manual-for-data-structures-
and-other-objects-using-c-4-e-michael-main-walter-savitch/
testbankmall.com
https://testbankmall.com/product/solution-manual-for-data-structures-
and-problem-solving-using-java-4-e-4th-edition-0321541405/
testbankmall.com
https://testbankmall.com/product/test-bank-for-data-structures-and-
algorithms-in-c-2nd-edition-by-goodrich/
testbankmall.com
Solution Manual for Data Structures and Algorithms in Java
1st Edition, Peter Drake
https://testbankmall.com/product/solution-manual-for-data-structures-
and-algorithms-in-java-1st-edition-peter-drake/
testbankmall.com
https://testbankmall.com/product/solution-manual-for-dynamics-of-
structures-4-e-4th-edition-0132858037/
testbankmall.com
https://testbankmall.com/product/solution-manual-for-data-structures-
and-problem-solving-using-c-2-e-mark-a-weiss/
testbankmall.com
https://testbankmall.com/product/solution-manual-for-c-programming-
program-design-including-data-structures-6th-edition-d-s-malik/
testbankmall.com
https://testbankmall.com/product/test-bank-for-general-organic-and-
biological-chemistry-structures-of-life-4-e-4th-edition-karen-c-
timberlake/
testbankmall.com
void sortDec(vector<int> & vec)
{ // bubble sort descending
bool sorted = false;
while (!sorted)
{
sorted = true;
for (auto i = 1; i < vec.size(); i++)
{
if (vec[i-1]< vec[i])
{
swap(vec[i],vec[i-1]);
sorted = false;
}
}
}
}
sortDec(topK);
for (auto i = k; i < nums.size(); i++)
{
if (nums[i] > topK[k-1])
{
for (auto j = k-2; j >=0 ; j--)
if (nums[i] < topK[j])
{topK[j+1] = nums[i]; break;}
else
topK[j+1] = topK[j];
if (topK[0] < nums[i])
topK[0] = nums[i];
}
}
return topK[k-1];
}
int main()
{
vector<int> nums;
int selected;
time_t start, end;
srand(time(NULL));
for (auto numInts = 1000; numInts<=10000; numInts+=1000)
// sizes 1,000, 2,000, 3,000, ...10,000
{
nums.resize(numInts);
start = time(NULL);
for (auto i = 0; i < 10; i++) // run 10 times
{
for (auto j = 0; j < numInts; j++)
nums[j] = rand()%(2*numInts);
selected = select1(nums); // or selected = select2(nums);
}
end = time(NULL);
cout<<numInts<<"\t"<<difftime(end,start)<<endl;
}
return 0;
}
180
160
140
120
100
Time of Select1
80
Time of Select2
60
40
20
0
0 2000 4000 6000 8000 10000 12000
2. /*
Word Puzzle problem
from the example in figure 1.1
*/
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include "matrix.h"
#include<algorithm>
struct Orientation
{
Orientation() : delRow(0), delCol(0) {}
Orientation operator() (int direction)
{
switch (direction)
{
case 0 : delRow = -1; delCol = -1; break;
case 1 : delRow = -1; delCol = 0; break;
case 2 : delRow = -1; delCol = 1; break;
case 3 : delRow = 0; delCol = -1; break;
case 4 : delRow = 0; delCol = 1; break;
case 5 : delRow = 1; delCol = -1; break;
case 6 : delRow = 1; delCol = 0; break;
case 7 : delRow = 1; delCol = 1; break;
}
return *this;
}
int delRow;
int delCol;
};
class Puzzle
{
public:
Puzzle(int numRows, int numCols )
{
matrix<char> temp(numRows,numCols);
puzzle= temp;
initPuzzle();
}
Puzzle(int numRows , int numCols , vector<string> wordList) : dictionary(wordList)
{
matrix<char> temp(numRows,numCols);
puzzle= temp;
initPuzzle();
}
void solvePuzzle();
void findWords(int startRow, int startCol, Orientation orient);
private:
void initPuzzle();
matrix<char> puzzle;
vector<string> dictionary;
};
void Puzzle::initPuzzle()
{
puzzle[0][0] = 't';
puzzle[0][1] = 'h';
puzzle[0][2] = 'i';
puzzle[0][3] = 's';
puzzle[1][0] = 'w';
puzzle[1][1] = 'a';
puzzle[1][2] = 't';
puzzle[1][3] = 's';
puzzle[2][0] = 'o';
puzzle[2][1] = 'a';
puzzle[2][2] = 'h';
puzzle[2][3] = 'g';
puzzle[3][0] = 'f';
puzzle[3][1] = 'g';
puzzle[3][2] = 'd';
puzzle[3][3] = 't';
}
void Puzzle::solvePuzzle()
{
Orientation orient;
for ( auto startRow = 0; startRow < puzzle.numrows(); startRow++)
for ( auto startCol=0; startCol < puzzle.numcols(); startCol++)
for (auto i = 0; i < 8 ; i++)
findWords(startRow,startCol,orient(i));
}
int main()
{
string diction[] = {"this", "two", "fat", "fats", "at", "wad", "ad", "hat", "that",
"his","is","it","ah"} ;
vector<string> dictionary(diction,diction+ 12);
Puzzle puzzle(MAXROWS, MAXCOLS, dictionary);
puzzle.solvePuzzle();
return 0;
}
1.3
void printDouble(double x)
{
if (x < 0)
{
cout<<"-";
x = -x;
}
int intPart = floor(x);
double fract = x - intPart;
printOut(intPart);
cout<<".";
while (fract<1 && fract > 0.0000000001)// 0.0000000001 is machine accuracy.
{
fract *= 10;
printDigit(floor(fract));
fract = fract - floor(fract);
}
}
1.4
which opens f il eNa me, does whatever processing is needed, and then closes it. If a line of the form
#include SomeFile
processFile( SomeFile );
is made recursively. Self-referential includes can be detected by keeping a list of files for which a call to
p ro ce s sF ile has not yet terminated, and checking this list before making a new call to p ro ce s sF ile .
1.5
1.6
void permute(const string & str, int low, int high)
{
char letter;
string tmp = str;
if (low >= high)
cout<<str<<endl;
else
{
for (auto i= low; i < str.size(); i++)
{
swap(tmp[0], tmp[i]);
permute(tmp, low+1, high);
}
}
}
1.7 (a) The proof is by induction. The theorem is clearly true for 0 < X 1, since it is true for X = 1, and for X
< 1, log X is negative. It is also easy to see that the theorem holds for 1 < X 2, since it is true for X = 2,
and for X < 2, log X is at most 1. Suppose the theorem is true for p < X 2 p (where p is a positive integer),
and consider any 2p < Y 4p (p 1). Then log Y = 1 + log( Y /2 ) < 1 + Y/2 < Y/2 + Y/2 Y, where the
(b) Let 2X = A. Then A B = ( 2 X ) B = 2 X B . Thus log A B = XB. Since X = log A, the theorem is proved.
1.8 (a) The sum is 4/3 and follows directly from the formula.
S 14 2
3
L . 4S 1 2
3
L .
(b) 42 43 4 42 Subtracting the first equation from the second gives
3S 1 1
2
L .
4 42 By part (a), 3S = 4/3 so S = 4/9.
S 14 4
9
L . 4S 1 4
9
163 L .
(c) 42 43 4 42 4 Subtracting the first equation from the second gives
3S 2 i
1i .
3S 1 3
5
7
L . 4i 4
4 42 43 Rewriting, we get i 0 i 0 Thus 3S = 2(4/9) + 4/3 = 20/9. Thus S =
20/27.
i4 .
N
i
(d) Let S N = i 0 Follow the same method as in parts (a) – (c) to obtain a formula for S N in terms of SN–1,
SN–2,..., S0 and solve the recurrence. Solving the recurrence is very difficult.
N N N / 2 1
1
i
1i 1
i
ln N ln N /2 ln 2.
i N / 2 i 1 i 1
1.9
1.10 24 = 16 1 (mod 5). (24)25 125 (mod 5). Thus 2100 1 (mod 5).
1.11 (a) Proof is by induction. The statement is clearly true for N = 1 and N = 2. Assume true for N = 1, 2, ... , k.
k 1 k
Fi Fi Fk 1.
Then i 1 i 1 By the induction hypothesis, the value of the sum on the right is Fk+2 – 2 + Fk+1 =
Fk+3 – 2, where the latter equality follows from the definition of the Fibonacci numbers. This proves the claim
and N = 2, the statement is true. Assume the claim is true for N = 1, 2, ... , k.
Fk 1 Fk Fk 1
by the definition, and we can use the inductive hypothesis on the right-hand side, obtaining
Fk 1 k k 1
1 k 1 2 k 1
Fk 1 ( 1 2 ) k 1 k 1
(c) See any of the advanced math references at the end of the chapter. The derivation involves the use of
generating functions.
N N N
(2i 1) 2 i 1
1.12 (a) i 1 i 1 i 1 = N( N + 1) – N = N2.
(b) The easiest way to prove this is by induction. The case N = 1 is trivial. Otherwise,
N 1 N
i3 ( N 1)3 i3
i 1 i 1
N 2 ( N 1) 2
( N 1)3
4
N2
( N 1) 2 ( N 1)
4
N 4N 4
2
( N 1) 2
4
( N 1) 2 ( N 2) 2
22
2
( N 1) ( N 2)
2
2
N 1
i
i 1
1.15
class EmployeeLastNameCompare
{
public:
bool operator () (const Employee & lhs, const Employee & rhs) const
{ return getLast(lhs.getName())< getLast(rhs.getName());}
};
1.16
matrix() : array(10)
{for( auto & thisRow : array )
thisRow.resize( 10 );
}
CATALOGUE
OF
NEW AND RECENT
BOOKS
PUBLISHED BY
MR. T. FISHER UNWIN.
London:
26, PATERNOSTER SQUARE.
1884.
Mr. Unwin takes pleasure in sending herewith a Catalogue of Books
published by him.
As each New Edition of it is issued, it will be sent post free to
Booksellers, Libraries, Book Societies, and Book Buyers generally—a
register being kept for that purpose.
Book Buyers are requested to order any Books they may require
from their local Bookseller.
Should any difficulty arise, the Publisher will be happy to forward
any Book, Carriage Free, to any Country in the Postal Union, on
receipt of the price marked in this list, together with full Postal
Address.
Customers wishing to present a book to a friend can send a card
containing their name and a dedication or inscription to be enclosed,
and it will be forwarded to the address given.
Remittances should be made by Money Order, draft on London,
registered letter, or half-penny stamps.
After perusal of this Catalogue, kindly pass it on to some Book-
buying friend.
CATALOGUE OF Mr T. FISHER
UNWIN’S PUBLICATIONS.
“Is a clear and useful little book, which is written with more
literary skill than is usually shown in such manuals. Mr.
Allardyce will no doubt do more important work.”—Athenæum.
“At the end Mr. Allardyce gives the useful example of how to
correct a proof—an art which some of those who live by the pen
never master thoroughly.”—Saturday Review.
“We have hardly any words but those of praise to give to his
very thoughtful, very dainty little book.”—Journal of Education.
“We can conceive no more desirable present to a literary
aspirant.”—Academy.
CENTENARY SERIES.
1. JOHN WICLIF, Patriot and Reformer: his Life and Writings. By
Rudolf Buddensieg, Lic. Theol., Leipsic. Parchment covers, Antique
printing. 2s.