Sunday, May 16, 2021

Gist vs Details

All of us have heard that 'the devil is in the detail', and is intended to mean that we should bother about the details.

But should we really?

Lets check a counter example, which would rather re-interpret 'the devil is in the detail' as don't get into the details or you will awaken the devil 😈

It is a major efficiency issue in many 'structured' organizations, several people focusing on details and the details going ping-pong, and finally what one could implement in a day taking months.

End result is a robust bullet proof museum worthy product crafted by hundreds. Why museum worthy? Oh its market is already taken by a product quickly patched together by a dozen

Just to clear out the air, this is metaphoric writing and 'details' is quite overloaded in its meaning.

Here is the counter example problem statement:

"We are hosting a tournament with 'n' number of participants.
If 'n' is even, we conduct n/2 matches and n/2 winners advance to next round.
If 'n' is odd, we give free pass to a random participant, and conduct (n-1)/2 matches with the remaining (n-1) participants. So the random lucky participant and (n-1)/2 winners advance to the next round.
The tournament thus proceeds with remaining participants till a champion is decided.
Calculate the total number of matches that need to be held in the tournament.
The Gist way of solving this problem: 
We need a champion. How do we get a champion? After n-1 participants lose. How do they lose? By  playing a match. So if we play n-1 matches, we eliminate n-1 participants, and we have a champion.
``But wait...what about odd, even and all that?``
What about it? Does it contradict the statement that every match conducted eliminates exactly one participant? ``Hmm, no... ``
Then, hey, its (n-1)

The Details way of solving this same problem:
``What about odd, even and all that?``
We change course here, and say ``No no, lets do some detailed analysis, we want to be sure we covered the odd/even part of the requirements``

Hang on tight as we get into the "detailed analysis :)"

Detailed Case Analysis:

Part 1: Formulate basic recursion:
Lets define matches required for a given number n as m(n).
"n teams need n/2 matches if n is even" translates to
m(2n) = n + m(n) ------> Eq.1
"n teams need (n-1)/2 matches if n is odd, and one gets a free pass" translates to
m(2n+1) = n + m(n) + 1 ------> Eq.2
From Eq.1 and 2:
m(2n+1) = m(2n) + 1 ------> Eq.3
Now, this is great that we can express m(2n+1) in terms of m(2n).
If we can calculate m(2n) in closed form, we can easily calculate m(2n+1) by adding a 1 to it.
We have base cases: m(1) = 0 and m(2) = 1.
Here, Eq.1 and Eq.2 are good, but they are discontinuous, in the sense that we have to ways to move ahead based on whether number of participants in odd or even
Eq.3 is better, but its still a one way relationship in the sense that we can go from even to next odd, but we don't have a way to go from an odd to next even.

Part 2:Derive a continuous recursion
So, lets try to formulate a recursion that is valid for all 'n' in a uniform way.
Lets consider m(2n+2)...
m(2n+2) = m(2(n+1)) = n+1+m(n+1) ---> Eq.4
 
Part 2.1: n is even:
Here we consider that n is even, which means n+1 is odd.
So, m(n+1) = m(n) + 1 based on Eq.2
Eq.4 reduces to:
m(2n+2) = (n+1 + m(n)) + 1 And from Eq.2 n+1+m(n) = m(2n+1)
So, For all even 'n', m(2n+2) = m(2n+1) + 1 -----> Eq5
 
Part 2.2: n is odd:
Here, we consider that n is odd, which means n = 2x+1, from some integer 'x'.
lets substitute this in m(n+1)
Then, m(n+1) = m(2x+1+1) = m(2x+2) = m(2x+1) + 1 (from Eq5 due courtesy Part2.1)
Now, lets plug back the value of n = 2x+1
We get for all odd n, m(n+1) = m(n) + 1 ---> Eq.6
So, we have proved that:
when n is even m(n+1) = m(n) + 1 (Eq.3)
when n is odd, m(n+1) = m(n) + 1(Eq.6)
And hence, 
For all n, m(n+1) = m(n) + 1 --> Eq.6
And thus we arrive at a continuous recursion of m(n) = m(n-1) + 1
 
Part 3: Arrive at the closed form from continuous recursion  
From base cases, m(1) = 0 and expanding Eq. 6:
m(n) = 1 + m(n-2) + 1 = 1 + 1 + m(n-3) + 1 = 1 + 1 + ... (n-2) times + m(1) + 1
m(n) = (n-2) + m(1) + 1 = n-2 + 0 + 1 = n -1 
m(n) = n-1 --> Eq.7 
Q.E.D
 
And here we see just the tips of devil's horns.
The claws, the thorny mace, and other gory tools of torture lie buried in the reviewing, standardizing, platforms, and ways of working  :-)

No comments: