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