Title: The Efficiency of Algorithms
1Chapter 3
- The Efficiency of Algorithms
2Figure 3.3 A Choice of Algorithms
3Figure 3.3.1 The Shuffle-Left Algorithm
Original Configuration
4Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit- First Copy
5Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit Second Copy
6Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit The Third Copy
7Figure 3.3.1 The Shuffle-Left Algorithm- The
Value of Legit After Last Item is Copied, the
Result is This
8Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit Reset the Right Hand Finger to
Start Again
9Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit Left and Right Hand Finger Move
Forward
10Figure 3.3.1 The Shuffle Left Algorithm The
Value of Legit Moving along, we pass over the
16.
11Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit-Seven Copies squeeze out O
12Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit - The 36, 42, 23, and 21 Are
Passed Over This is the Result
13Figure 3.3.1 The Shuffle-Left Algorithm The
Value of Legit Squeezing out Final 0 Gives This
Result
14Figure 3.3.1 The Shuffle Left Algorithm The
Value of Legit The Left Hand Finger is Pointing
At a Nonzero Element, so Another Advance of Both
Fingers Gives Us This Configuration.
15Figure 3.3.2 The Copy-Over Algorithm
16Figure 3.3.3 The Converging-Pointers Algorithm
The Value of Legit
17Figure 3.3.3 The Converging-Pointers Algorithm
The Value of Legit Legit and Right Are Reduced
by 1.
18Figure 3.3.3 The Converging-Pointers Algorithm
The Value of Legit The Value of Left Increases
19Figure 3.3.3 The Converging-Pointers Algorithm
The Value of Legit Position Right is Copied
Into Position Left
20Figure 3.3.3 The Converging-Pointers Algorithm
The Value of Legit Item at Position Left is
Still 0, Another Copy Takes Place
21Practice Problems - In the Data Cleanup Problem,
Suppose the Original Data Is Like This
22Figure 3.6 Values of Magnitude Work 2n
23Figure 3.7 Order of Magnitude - Work cn for
Various Values of c
24Figure 3.8 Order of Magnitude Growth of Work
cn for Various Values of c
25Figure 3.9 Order of Magnitude -Table of Calling
Information
26Figure 3.10 Order of Magnitude Work cn2 for
Various Values c
27Figure 3.11 The 0rder of Magnitude A
Comparison of n and n2
28Figure 3.12 Order of Magnitude For Large
Enough n, 0.25n2 Has Larger Values than 10n
29Figure 3.13 Order of Magnitude A Comparison of
Two Extreme T (n2) and T (n) Algorithms
30Using the Information in Figure 3.5 Fill in the
Above Table for the Number of Comparisons
required in the Sequential Search Algorithm
31Figure 3.14 Analysis of Algorithms Analysis of
Three Data Cleanup Algorithms
32Figure 3.16 Selection Sort Algorithms
Comparisons Required by Selection Sort
33Figure 3.17 Selection Sort Algorithms - An
Attempt to Exchange the Values at X and Y
34Figure 3.18 Selection Sort Algorithms
Exchanging the Values of X and Y
35Figure 3.21 Binary Search Values of n and lg n
36Figure 3.22 Binary Search A comparison of n
and lg n
37Figure 3.23 Summary Order-of-Magnitude Time
Efficiency Summary
38Figure 3.24 When Things Get Out of Hand Four
Connected Cities
39Figure 3.25 When Things Get Out of Hand
Hamiltonian Circuits Among All Paths from A in
Figure 3.24 with Four Links
40Figure 3.26 (a) When Things Get Out of Hand
Comparisons of lg n, n, n2, and 2n
41Figure 3.26 (b) When Things Get Out of Hand
Comparisons of lg n,n, n2, and 2n
42Figure 3.28 Approximation Problems A First-Fit
Solution to a Bin-Packing Problem
43Practice Problems Tree Shows All Paths with Two
Links That Begin At Node A
44Exercises Write the Data List that Results from
running the Shuffle-Left Algorithm to clean up
this Data
45Exercises A Linked List
46Exercises Draw a Linked List when Data Cleanup
is Performed on This Linked List