the efficient postcode

9
The efficient postcode A postmaster in Zejtun had to invent an efficient postcode in such a manner that he would not waste any numbers and that any number could uniquely identify one house in his district. His district consisted of 3 locations: Zejtun, Ramla and Bir-id-deheb, Zejtun had 200 houses, Ramla had 100 and Bir-id-deheb had another 100. Each house had 10 people living in it. At the post-office he had a pigeonhole shelving for 400 addresses. How could he invent a code, such that each code would identify uniquely on residence, that from the number the postman could directly know which location it was for. So he gave the following addresses within each location: Zejtun: from 000 to 199; Ramla: from 00 to 99; Bir-id-deheb: from 00 to 99; Now he had to adapt the code so that each house in the district had a unique address, so he adopted the following code: Zejtun: from 0 to 199; Ramla: from 200 to 299; Bir-id-deheb: from 300 to 399 In this manner the postman knew that if the code started with 0 or 1 it was intended for Zejtun, with 2 it was for Ramla and 3 it was for bir-id-deheb. So he organised his pigeonhole shelving as follows: ADDRESS LOCATION ADDRESS WITHIN LOCATION [000] Zejtun [000] ... [199] [199] [200] Ramla [00] ... [299] [99] [300] Bir-id-deheb [00] ... [399] [99]

Upload: john-cutajar

Post on 14-Dec-2014

1.335 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: The efficient postcode

The efficient postcode

A postmaster in Zejtun had to invent an efficient postcode in such a manner that he

would not waste any numbers and that any number could uniquely identify one house

in his district.

His district consisted of 3 locations: Zejtun, Ramla and Bir-id-deheb, Zejtun had 200

houses, Ramla had 100 and Bir-id-deheb had another 100. Each house had 10 people

living in it.

At the post-office he had a pigeonhole shelving for 400 addresses. How could he invent

a code, such that each code would identify uniquely on residence, that from the number

the postman could directly know which location it was for.

So he gave the following addresses within each location:

Zejtun: from 000 to 199; Ramla: from 00 to 99; Bir-id-deheb: from 00 to 99;

Now he had to adapt the code so that each house in the district had a unique address, so

he adopted the following code:

Zejtun: from 0 to 199; Ramla: from 200 to 299; Bir-id-deheb: from 300 to 399

In this manner the postman knew that if the code started with 0 or 1 it was intended for

Zejtun, with 2 it was for Ramla and 3 it was for bir-id-deheb.

So he organised his pigeonhole shelving as follows:

ADDRESS LOCATION ADDRESS WITHIN LOCATION [000]

Zejtun [000]

... [199] [199] [200]

Ramla [00]

... [299] [99] [300]

Bir-id-deheb [00]

... [399] [99]

Page 2: The efficient postcode

However at Ramla, the houses were small and could host only 5 persons. So he

combined two houses together, with the same address, in such a way that each address

would involve a whole family of 10 persons.

He then had the idea to organise a demonstration to the people in each village to explain

the working of the new code. So he organised a minibus service which would pick a

particular family from each location and bring them to the post office for a

demonstration. What should be the capacity of this minibus? Obviously 10 since each

household consisted of 10 persons.

ADDRESS LOCATION ADDRESS WITHIN LOCATION [000]

Zejtun [000]

... [199] [199] [200]

Ramla [00] [00]

... ... [299] [99] [99] [300]

Bir-id-deheb [00]

... [399] [99]

10-BIT

Page 3: The efficient postcode

199

00

99

Zejtun

Bir-id-Deheb

000

00

99

Ramla

Starting with 0 or 1

Starting with 2

Starting with 3

Zejtun sub post office

Ramla sub post office

Bir-id-Deheb sub post office

[000]

[200]

[299]

[199]

[300]

[399]

Page 4: The efficient postcode

Modern times had this postmaster program an automatic selector to sort the mail to

individual sub-post offices in each location.

For example an address of 223 would mean house number 23 at Ramla, an address of

166 would mean house 166 in Zejtun and an address of 325 would mean house 25 in

Bir-id-deheb.

A2

A1

A0

0

1

2

3

Full Address Zejtun

Ramla

Bir-id-deheb

A2

A1

A0

A1

A0

A1

A0

Page 5: The efficient postcode

POSTMASTER GOT TRANSFERED

The big success in the code he had invented, made him famous, and with fame came all

the envy of his colleagues which started inventing rumours which led the post master

general to transfer him to Binland, a place where people could only count up to 1. In fact

these people did all their mathematics in binary (base 2) and to avoid confusion, in

speaking, they adopted a Hexadecimal notation (base 16).

In this land there were only two places, one called ROM and the other called RAM each

had 256 locations and the Central Postal Unit could address all 512 locations in this

land. So he had to adopt the postcode system to this new land.

Not being such a good mathematician, he had to get acquainted with binary numbers.

To do this he adopted a table which gave him the number of digits required to have a

number of unique addresses:

From this table he deducted that to be able to address all the 512 locations in his land he

had to have an address which is 9 bits long and since each place had 256 locations, each

had to have an address of 8 bits within the place.

Since each location contained 8 bits as the inhabitants of Binland were called, the bus

carrying the bits from each loction had to be 8 bit wide.

Soon he realised that this was an even simpler case than he had before

n = number of bits in address 2n = number of addressable locations 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512

10 1024 ( called 1Kilo) 20 1024x1024 (called 1Mega) 30 1024x1024x1024 (called 1Giga) 40 1024x1024x1024x1024 (called 1Tera)

Page 6: The efficient postcode

ROM

RAM

[00000000B] = [00H]

[11111111B] = [FFH]

[00000000B] = [00H]

[11111111B] = [FFH]

[000000000B] = [000H]

[011111111B] = [0FFH]

[100000000B] = [100H]

[111111111B] = [1FFH]

Starts with 0

Starts with 1

The automatic machine he programmed was even Simpler:

A8

A7

A6

A5

A4

A3

A2

A1

A0

A0 A1 A2 A3 A4 A5 A6 A7

A0 A1 A2 A3 A4 A5 A6 A7

RAM

ROM 0

1

Page 7: The efficient postcode

Just as he had launched the new system, the postmaster general called him to announce

that a new place called I/O had been added to his district, and that he had to cater for

their mail too.

After a few minutes of rage, the postmaster couldn’t be bothered to redo everything

from scratch. So he decided to keep the I/O on a separate map and introduced a new

signal stamp called M/IO’ which indicated if the mail was addressed to the Main portion

or the I/O section. Thus if this signal was 1 it would indicate that the address is referring

to the Main and if it was 0 the address would be referring to I/O.

M/IO’ A8...A0 Section A7...A0

1 [000H] ROM

[00H] ... [0FFH] [FFH] [100H]

RAM [00H]

... [1FFH] [FFH]

M/IO’ A8...A0 Section A8...A0

0

[000H]

I/O

[000H] ...

[1FFH] [1FFH]

A8

A7

A6

A5

A4

A3

A2

A1

A0

A0 A1 A2 A3 A4 A5 A6 A7

A0 A1 A2 A3 A4 A5 A6 A7

RAM

ROM

0

1

M/IO’

A0 A1 A2 A3 A4 A5 A6 A7

I/O

A8

1

0

1

Page 8: The efficient postcode

This solution could accomodate an extra 512 locations in I/O. Yet being on a separate

map, locations in I/O felt a bit Isolated. Also this added extra complexity to the machine

which consequently made mail distribution slower. The postmaster also noticed that

512 addresses for I/O were superfluous and that actually there were only 256

addresses needed for this place.

So one fine day he decided it would be

better to map everything together on a

single map. He noticed that to do this the

address would need another bit since now

the locations had become 768 locations.

With the 10th bit in the address added, he

would be able to address 1024 locations

which would leave 256 locations for further

expansion.

So he redrew the map from scratch.

A9...A0 Section A7...A0 000H]

ROM [00H]

... [0FFH] [FFH] [100H]

RAM [00H]

... [1FFH] [FFH] [200H]

I/O [00H]

... [2FFH] [FFH] [300H]

Expansion [00H]

[3FFH] [FFH]

A8

A7

A6

A5

A4

A3

A2

A1

A0

A0 A1 A2 A3 A4 A5 A6 A7

A0 A1 A2 A3 A4 A5 A6 A7

RAM

ROM

A0

A1

A2

A3

A4

A5

A6

A7

I/O

A9

00

01

10

11

0

1

2

3

CPU

Page 9: The efficient postcode

The Sorting Machine – also called Address Decoder