11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

556 Chap. 17 Limits to Comput<strong>at</strong>ionwe cannot analyze. This comes as a result of the fact th<strong>at</strong> the Halting Problem isunsolvable.17.3.1 UncountabilityBefore proving th<strong>at</strong> the Halting Problem is unsolvable, we first prove th<strong>at</strong> not allfunctions can be implemented as a computer program. This must be so because thenumber of programs is much smaller than the number of possible functions.A set is said to be countable (or countably infinite if it is a set with an infinitenumber of members) if every member of the set can be uniquely assigned to apositive integer. A set is said to be uncountable (or uncountably infinite) if it isnot possible to assign every member of the set to its own positive integer.To underst<strong>and</strong> wh<strong>at</strong> is meant when we say “assigned to a positive integer,”imagine th<strong>at</strong> there is an infinite row of bins, labeled 1, 2, 3, <strong>and</strong> so on. Take a set<strong>and</strong> start placing members of the set into bins, with <strong>at</strong> most one member per bin. Ifwe can find a way to assign all of the set members to bins, then the set is countable.For example, consider the set of positive even integers 2, 4, <strong>and</strong> so on. We canassign an integer i to bin i/2 (or, if we don’t mind skipping some bins, then we canassign even number i to bin i). Thus, the set of even integers is countable. Thisshould be no surprise, because intuitively there are “fewer” positive even integersthan there are positive integers, even though both are infinite sets. But there are notreally any more positive integers than there are positive even integers, because wecan uniquely assign every positive integer to some positive even integer by simplyassigning positive integer i to positive even integer 2i.On the other h<strong>and</strong>, the set of all integers is also countable, even though this setappears to be “bigger” than the set of positive integers. This is true because we canassign 0 to positive integer 1, 1 to positive integer 2, -1 to positive integer 3, 2 topositive integer 4, -2 to positive integer 5, <strong>and</strong> so on. In general, assign positiveinteger value i to positive integer value 2i, <strong>and</strong> assign neg<strong>at</strong>ive integer value −i topositive integer value 2i + 1. We will never run out of positive integers to assign,<strong>and</strong> we know exactly which positive integer every integer is assigned to. Becauseevery integer gets an assignment, the set of integers is countably infinite.Are the number of programs countable or uncountable? A program can beviewed as simply a string of characters (including special punctu<strong>at</strong>ion, spaces, <strong>and</strong>line breaks). Let us assume th<strong>at</strong> the number of different characters th<strong>at</strong> can appearin a program is P . (Using the ASCII character set, P must be less than 128, butthe actual number does not m<strong>at</strong>ter). If the number of strings is countable, thensurely the number of programs is also countable. We can assign strings to thebins as follows. Assign the null string to the first bin. Now, take all strings ofone character, <strong>and</strong> assign them to the next P bins in “alphabetic” or ASCII codeorder. Next, take all strings of two characters, <strong>and</strong> assign them to the next P 2 bins,again in ASCII code order working from left to right. Strings of three characters

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!