Educational program for working with punch cards (or the story of how “big data” were processed from 1890 to 1970)
In the period 1890-1970, all processing of big data was carried out through punch cards. Punch cards, in turn, were processed using so-called. “Recording equipment”, the central element of which was the electromechanical “punch card sorter”. Punch cards and related equipment were used to solve a wide variety of tasks: population census, accounting, inventory, payroll, etc.
How did people work with punch cards? What algorithm followed the electromechanical punch card sorter? How did you sort by numeric data fields? And on the string? About all this - below.
A striking feature of the pre-computer times recording equipment: it was originally completely electromechanical. There was not even tube electronics in it. The “intelligence” of the recording equipment was built from wire brushes (for recognizing holes in punch cards), an electromechanical relay and mechanical wheels (for summing up values). Despite its technological primitiveness, the “recording equipment” at one time revolutionized the processing of big data.
How did people work with punch cards?
Each punch card stored one data record (up to 80 numbers or characters). Each data record consisted of several fields. The punch card sorter arranged the cards in the correct order for the operator (one of the data fields), after which the machine, called the “tabulator”, read the sorted punch cards, extracted the required fields from them (again, set by the operator), and printed a report.
For example, consider how punched cards were used in processing invoices. For companies, for each invoice submitted for payment, a separate punched card was provided (see the example in the figure below). On the punch card indicated such data fields as the vendor number, date of payment, amount of payment, etc.
Appropriate automated data processing business process is as follows. The punch card sorter is given the command to order punch cards by supplier number. After the sorting is completed, the punch cards are transmitted to the tabulator, which generates a report, reading the required line from each punch card. A mechanical counter embedded in the tabulator automatically forges the total amount.
Many other business processes, such as payroll, inventory, and billing, were done in pre-computer times in the same way.
The principle of operation of the electromechanical punch card sorter
The sorter takes a stack of punched cards and sorts them according to the data field specified by the operator. For example, the affiliation of employees to a particular department. What for? As an option, having previously grouped employees by department, then generate a report on the implementation of the sales plan by each of the departments of the company.
To solve this problem, punched cards are first sorted on the basis of the “department” field, and then transferred to the tabulator, which summarizes the “sales” field, printing in the report intermediate results for each department.
The operator places the punch card in need of sorting in a special tray, from which they are driven one by one through the sorter. The sorter reads punch cards and distributes them into 13 pockets: ten digital, two “zonal” (for processing string values); and one for discarded punched cards (on which the value by which the sorting was performed) is not specified.
The algorithm by which the punch card sorter works is very different from the generally accepted algorithms today. The key difference is that punch cards do not compare with each other.
Algorithm of bitwise sorting of numbers
How, then, does the punch card sorter manage to cope with their work? It implements an elegant “bitwise sorting” algorithm. Essence: the punch card sorter processes one digit of the data field at a time; to sort by three-digit field, a deck of punched cards must be passed through the sorter three times. So, the algorithm:
By ordering punch cards by a numeric data field specified by the operator, the sorter processes only the low-order bit of this field during the first run. And in accordance with the value of this category, it decides where to drop the current punch card: which of the 10 digital pockets (from zero to ninth).
After the sorter has completed the distribution of punch cards in the pockets, the operator takes them out and folds them into a common pack. In order: from the zero pocket to the ninth.
The operator again puts the assembled punch card into the sorter, and repeats steps 1 and 2 sequentially for each digit.
Everything, now punched cards are sorted.
Advantages of the Bitwise Sorting Algorithm
The bitwise sorting algorithm is elegant and fast. Its computational complexity is O (n log n). In other words, as the number of cards increases, the duration of the algorithm increases linearly, rather than exponentially.
The algorithm of bitwise sorting can technically be implemented in the form of a simple electromechanical design.
Despite the fact that no more than 3,600 cards are placed in the input tray of the punch card sorter, it can sort and a much larger number of punched cards if the operator performs the following two actions in a timely manner: (1) load new punch cards into the tray in time; (2) to empty digital pockets in a timely manner (so that they do not overflow).
How to encode string data
As noted above, the numerical values are encoded on the punched card with holes. One hole in the column. We have already sorted out their sorting. It now remains to understand how the punch cards encode the lines and how the punch card sorter organizes them.
To work with lines, two “zonal” pockets (11th and 12th) are provided in the punch card sorter, in addition to 10 pith ones. The principle of encoding alphabetic characters is as follows (see figure below). Each letter is encoded by two holes on a punched card: a hole in the number (from 1 to 9) and a hole in the "zone" (0, 11 or 12).
Please note: the string with zeros is digital when processing numeric data fields, and “zonal” when processing string data fields.
Algorithm for sorting character strings
Thanks to this encoding, the sorter can sort the string data fields alphabetically. On this he needs two runs. The algorithm is as follows:
On the first run, the punch sorter orders the cards in much the same way as when sorting numeric data fields. The difference is that in alphabetical sorting only nine pockets are involved: from the 1st to the 9th.
At the end of the sorting, the operator removes punch cards from digital pockets. Again, in order (as is the case with the ordering by the numeric data field): starting with the first pocket and ending with the ninth. The operator sends the assembled pack of cards for sorting a second time.
On the second run, the punch card sorter reads only the lines of the “zones” (0, 11 and 12), and ignores the lines with numbers.
As a result, the ordered punch cards are distributed by the sorter into three “zonal” pockets: from A to I are placed in the 12th pocket; from J to R - in the 11th; from S to Z - to 0th.
If the sorting needs to be performed not by one first character, but for example, by two or three first, then the process described above (steps one through four) is performed sequentially for each character. Those. for each character, two runs are made through the punch card sorter.
So, when there were no computers yet, enterprises processed large data using punched cards. Despite the fact that punch cards are irrevocably outdated, we are still confronted with their influence on the current state of computer technology - every time we have to put up with text formatting with 80-character strings. Something similar is observed, for example, when working with Far Manager.