The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
The RAM Model of Computation Next: BestWorst, and Average-Case Up: Keeping Score Previous: Keeping Score The RAM Model of Computation Machine-independent algorithm design depends upon a hypothetical computer called the Random Access Machine or RAM. Under this model of computation, we are confronted with a computer where: ● Each ``simple'' operation (+, *, -, =, if, call) takes exactly 1 time step. ● Loops and subroutines are not considered simple operations. Instead, they are the composition of many single-step operations. It makes no sense for ``sort'' to be a single-step operation, since sorting 1,000,000 items will take much longer than sorting 10 items. The time it takes to run through a loop or execute a subprogram depends upon the number of loop iterations or the specific nature of the subprogram. ● Each memory access takes exactly one time step, and we have as much memory as we need. The RAM model takes no notice of whether an item is in cache or on the disk, which simplifies the analysis. Under the RAM model, we measure the run time of an algorithm by counting up the number of steps it takes on a given problem instance. By assuming that our RAM executes a given number of steps per second, the operation count converts easily to the actual run time. The RAM is a simple model of how computers perform. A common complaint is that it is too simple, that these assumptions make the conclusions and analysis too coarse to believe in practice. For example, multiplying two numbers takes more time than adding two numbers on most processors, which violates the first assumption of the model. Memory access times differ greatly depending on whether data sits in cache or on the disk, thus violating the third assumption. Despite these complaints, the RAM is an excellent model for understanding how an algorithm will perform on a real computer. It strikes a fine balance by capturing the essential behavior of computers while being simple to work with. We use the RAM model because it is useful in practice. Every model has a size range over which it is useful. Take, for example, the model that the earth is flat. You might argue that this is a bad model, since the earth is not flat. However, when laying the foundation of a house, the flat earth model is sufficiently accurate that it can be reliably used. Further, it is so much easier to manipulate a flat-earth model that it is inconceivable that you would try to think spherically when you don't have to. The same situation is true with the RAM model of computation. We make an abstraction that in general is very useful. It is quite difficult to design an algorithm such that the RAM model will give you file:///E|/BOOK/BOOK/NODE12.HTM (1 of 2) [19/1/2003 1:28:08]
The RAM Model of Computation substantially misleading results, by performing either much better or much worse in practice than the model suggests. The robustness of the RAM enables us to analyze algorithms in a machine-independent way. Next: BestWorst, and Average-Case Up: Keeping Score Previous: Keeping Score Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK/NODE12.HTM (2 of 2) [19/1/2003 1:28:08]
- Page 61 and 62: References J. M. Chambers. Partial
- Page 63 and 64: References CT80 CT92 1971. G. Carpa
- Page 65 and 66: References K. Daniels and V. Milenk
- Page 67 and 68: References (FOCS), pages 60-69, 199
- Page 69 and 70: References FM71 M. Fischer and A. M
- Page 71 and 72: References History of Computing, 7:
- Page 73 and 74: References N. Gibbs, W. Poole, and
- Page 75 and 76: References Hof82 Hof89 Hol75 C. M.
- Page 77 and 78: References IK75 Ita78 O. Ibarra and
- Page 79 and 80: References Kir83 D. Kirkpatrick. Ef
- Page 81 and 82: References object in 2-dimensional
- Page 83 and 84: References LT79 LT80 8:99-118, 1995
- Page 85 and 86: References Mil97 V. Milenkovic. Dou
- Page 87 and 88: References Theoretical Computer Sci
- Page 89 and 90: References Pav82 T. Pavlidis. Algor
- Page 91 and 92: References Rei72 Rei91 Rei94 E. Rei
- Page 93 and 94: References Prentice Hall, Englewood
- Page 95 and 96: References SR95 SS71 SS90 SSS74 ST8
- Page 97 and 98: References Tin90 Mikkel Thorup. On
- Page 99 and 100: References Wel84 T. Welch. A techni
- Page 101 and 102: References Algorithms Mon Jun 2 23:
- Page 103 and 104: Correctness and Efficiency Next: Co
- Page 105 and 106: Correctness NearestNeighborTSP(P) P
- Page 107 and 108: Correctness Figure: A bad example f
- Page 109 and 110: Efficiency Next: Expressing Algorit
- Page 111: Keeping Score Next: The RAM Model o
- Page 115 and 116: Best, Worst, and Average-Case Compl
- Page 117 and 118: The Big Oh Notation Figure: Illustr
- Page 119 and 120: Logarithms Next: Modeling the Probl
- Page 121 and 122: Logarithms justified in ignoring th
- Page 123 and 124: Modeling the Problem Figure: Modeli
- Page 125 and 126: About the War Stories Next: War Sto
- Page 127 and 128: War Story: Psychic Modeling Next: E
- Page 129 and 130: War Story: Psychic Modeling have pu
- Page 131 and 132: War Story: Psychic Modeling Next: E
- Page 133 and 134: Exercises (b) If I prove that an al
- Page 135 and 136: Fundamental Data Types Next: Contai
- Page 137 and 138: Containers Next: Dictionaries Up: F
- Page 139 and 140: Dictionaries Next: Binary Search Tr
- Page 141 and 142: Binary Search Trees BinaryTreeQuery
- Page 143 and 144: Priority Queues Next: Specialized D
- Page 145 and 146: Specialized Data Structures Next: S
- Page 147 and 148: Sorting Next: Applications of Sorti
- Page 149 and 150: Applications of Sorting Figure: Con
- Page 151 and 152: Data Structures Next: Incremental I
- Page 153 and 154: Incremental Insertion Next: Divide
- Page 155 and 156: Randomization Next: Bucketing Techn
- Page 157 and 158: Randomization Next: Bucketing Techn
- Page 159 and 160: Bucketing Techniques Algorithms Mon
- Page 161 and 162: War Story: Stripping Triangulations
<strong>The</strong> RAM Model of Computation<br />
Next: BestWorst, and Average-Case Up: Keeping Score Previous: Keeping Score<br />
<strong>The</strong> RAM Model of Computation<br />
Machine-independent algorithm design depends upon a hypothetical computer called the Random Access<br />
Machine or RAM. Under this model of computation, we are confronted with a computer where:<br />
● Each ``simple'' operation (+, *, -, =, if, call) takes exactly 1 time step.<br />
● Loops and subroutines are not considered simple operations. Instead, they are the composition of<br />
many single-step operations. It makes no sense for ``sort'' to be a single-step operation, since<br />
sorting 1,000,000 items will take much longer than sorting 10 items. <strong>The</strong> time it takes to run<br />
through a loop or execute a subprogram depends upon the number of loop iterations or the<br />
specific nature of the subprogram.<br />
● Each memory access takes exactly one time step, and we have as much memory as we need. <strong>The</strong><br />
RAM model takes no notice of whether an item is in cache or on the disk, which simplifies the<br />
analysis.<br />
Under the RAM model, we measure the run time of an algorithm by counting up the number of steps it<br />
takes on a given problem instance. By assuming that our RAM executes a given number of steps per<br />
second, the operation count converts easily to the actual run time.<br />
<strong>The</strong> RAM is a simple model of how computers perform. A common complaint is that it is too simple,<br />
that these assumptions make the conclusions and analysis too coarse to believe in practice. For example,<br />
multiplying two numbers takes more time than adding two numbers on most processors, which violates<br />
the first assumption of the model. Memory access times differ greatly depending on whether data sits in<br />
cache or on the disk, thus violating the third assumption. Despite these complaints, the RAM is an<br />
excellent model for understanding how an algorithm will perform on a real computer. It strikes a fine<br />
balance by capturing the essential behavior of computers while being simple to work with. We use the<br />
RAM model because it is useful in practice.<br />
Every model has a size range over which it is useful. Take, for example, the model that the earth is flat.<br />
You might argue that this is a bad model, since the earth is not flat. However, when laying the foundation<br />
of a house, the flat earth model is sufficiently accurate that it can be reliably used. Further, it is so much<br />
easier to manipulate a flat-earth model that it is inconceivable that you would try to think spherically<br />
when you don't have to.<br />
<strong>The</strong> same situation is true with the RAM model of computation. We make an abstraction that in general<br />
is very useful. It is quite difficult to design an algorithm such that the RAM model will give you<br />
file:///E|/BOOK/BOOK/NODE12.HTM (1 of 2) [19/1/2003 1:28:08]