Thursday, September 2, 2010

(W)rote something that came to my head today.

The G&O Algorithm
This algorithm is one of the popular classics. Let us have an analytical look at it.

Firstly, is it an algorithm in the first place?

The answer to this is in the affirmative.
The algorithm is used to score excellent marks in examinations. It fulfils the
five conditions as outlined by Knuth.


1. Finiteness:
It terminates in a finite number of steps. They will be enumerated in a later section.

2. Definiteness:

Each step is properly defined, nay, perfected through generations of practice. Entire Vedas were handed down by a variant of this algorithm (This variant was a major deviation since it also involves handing down the detailed meanings and interpretations of those texts).

3. Input:

An open textbook is scanned line by line or character by character. Number of inputs is a function of the declared syllabus and the part the student deems optional.

4. Output:
The output is same as the input text, replicated on a piece of paper, in a time bound, communal ritual.

5. Effectiveness:
The deviation of the text from the original is evaluated by an expert set of pattern matching personnel who determine the percentage error and assign a grade. This grade is effectively used by the user of the algorithm for a variety of purposes for at least one year after it is declared and forgotten later. Used traditionally as a benchmark for intelligence and capability.  Thus it is effective in fulfilling its purpose of helping the user get maximum marks or a high grade.

What is the definition of this algorithm:

As the name suggests, there are two parts to this. G and O. We will define them in that order.

G (Ghokaa):

Inputs:
i <-- First chapter of syllabus
l <-- Last chapter of syllabus
o <-- S :{ x | Chapter x is deemed optional}



Start:
G1. Open the textbook. (Choice of textbook is a separate algorithm named after the legendary authors N.R.Lee and T.K.Max and follows the Law of Approaching Nationality)

G2. Move to chapter number i.

G3. If i is not equal to o, learn chapter i by rote. (Concept, practical application, mathematical meaning and any inconsistency with past knowledge can be neglected at this stage.)

G4. Repeat step G3.

G5. Repeat step G4.  // Note the distinction between repeat and go to.

G6. Sleep. Can you blurt out the input in your sleep? If yes, wake up and go to G7. Else, go to step G4.

G7. If i is not greater than l, advance i by one. Go to step G3.

G8. Is it time for the exam to start? If yes then close the textbook, get
ready for the exam and move to step O1.  Else, go to step G9.

G9. Read anything from the textbook which is a subset of the declared syllabus.

Here the author digresses to apologise to Mithunda for dragging G9 into this.
 
O (Okaa):

q <-- 1
m <-- total number of questions in the paper

O1. Is q less than m? If yes, replicate the input text corresponding to the relevant question, ad verbatim, onto the paper.  Else go to O3.

O2. Advance q by one. Go to step O1.

O3. Is the exam over? If yes, get out of the hall according to protocol.

End.

Complexity Analysis:

Although it can be analytically calculated that the complexity of this algorithm is in Theta[N], where N = n-i-no, where no = n(S), heuristics show that this algorithm always completes in Constant time, even in the worst case.


T(G&O) = Theta(1)

It has been shown that:

T(G&O) == [K hours before the examination timing] + [E]
where,  K = Constant determined by the student
E = Constant Exam Duration as determined by the powers that be

Thus, we conclude our introductory study of the G&O algorithm. For a detailed study, the interested reader may refer to ...
Why? Are the details in the syllabus? No? Never mind the details then.
In the next section, The Law of Approaching Nationality will be examined.