{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

9 chapter 3 computing with large integers 31

Info icon This preview shows pages 14–17. Sign up to view the full content.

View Full Document Right Arrow Icon
9
Image of page 14

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Chapter 3 Computing with Large Integers 3.1 Complexity Theory When presenting an algorithm, we shall always use a high-level, and somewhat informal, notation. However, all of our high-level descriptions can be routinely translated into the machine-language of an actual computer. So that our theorems on the running-times of algorithms have a precise math- ematical meaning, we formally define an “idealized” computer: the Random Access Machine or RAM . A RAM consists of an unbounded sequence of memory cells m [0] , m [1] , m [2] , . . . each of which can store an arbitrary integer, together with a program . A program consists of a finite sequence of instructions I 0 , I 1 , . . . , where each instruction is of one of the following types: arithmetic This type of instruction is of the form x y z , where represents one of the operations addition, subtraction, multiplication, or integer division. The values y and z are of the form c , m [ a ], or m [ m [ a ]], and x is of the form m [ a ] or m [ m [ a ]], where c is an integer constant and a is a nonnegative integer constant. Execution of this type of instruction causes the value y z to be evaluated and then stored in x . branching This type of instruction is of the form IF y z GOTO i , where i is the index of an instruction, and where is one of the comparison operators = , 6 = , <, >, , , and y and z are as above. Execution of this type of instruction causes the “flow of control” to pass conditionally to instruction I i . halt The HALT instruction halts the execution of the program. A RAM executes by executing instruction I 0 , and continues to execute instructions, following branching instructions as appropriate, until a HALT instruction is executed. We do not specify input or output instructions, and instead assume that the input and output are to be found in memory at some prescribed location, in some prescribed format. To determine the running-time of a program on a given input, we charge 1 unit of time to each instruction executed. This model of computation closely resembles a typical modern-day computer, except that we have abstracted away many annoying details. However, there are two details of real machines that 10
Image of page 15
cannot be ignored; namely, any real machine has a finite number of memory cells, and each cell can store numbers only in some fixed range. The first limitation must be dealt with by either purchasing sufficient memory or designing more space-efficient algorithms. The second limitation is especially annoying, as we will want to perform computations with quite large integers—much larger than will fit into any single memory cell of an actual machine. To deal with this limitation, we shall represent such large integers as vectors of digits to some base, so that each digit is bounded so as to fit into a memory cell. This is discussed in more detail in the next section. Using this strategy, the only other numbers we actually need to store in memory cells are “small” numbers representing array indices, addresses, and the like, which hopefully will fit into the memory cells of actual machines.
Image of page 16

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern