Monday, July 20, 2015

Today we continue reading the book "Give and Take".
 We discussed "Expedition behavior" and "responsibility bias". The former involves putting the group's interests before self and the latter involves overestimating your own contributions.
 The former fosters successful collaborations while the latter attributes to failed collaborations. As with networking and collaboration, reciprocity comes in useful to spotting and gathering talent around us. In many studies, when the manager showed  a belief that the employees are bloomers (ones who show potential for intellectual blooming or "spurting") employees bloomed. Having a genuine interest and belief as well as engaging in actions that support others, increases other's motivation and helps them achieve their potential.
Matchers are in fact better equipped to inspire and promote this talent growth. First since they believe in reciprocity, they go out of their way to support and encourage. Besides they do so only when they have seen an evidence of a promise. Givers don't wait for these signs of potential. Givers start by viewing other people as bloomers.
These roles can also be seen to affect the two fundamental paths to influence which are dominance and prestige.  Dominance is established when others see us as strong, powerful and authoritative. Prestige is established when others respect and admire us. Takers are attracted to and excel in dominance. They specialize in powerful communication.
#codingexercise
Double
GetNthRootProductEvenRaisedPDividedQAndOddRaisedPTimesQ (Double [] A,Double  p, Double q)

{

If ( A== null) return 0;

Return A.NthRootProductEvenRaisedPDividedQAndOddRaisedPTimesQ(p, q);

}

Sunday, July 19, 2015

Today we start reading another book called Give and Take by Adam Grant. This book breaks out of the mold of self-improvement books in that it shifts the focus from individual drivers of success : passion, hard-work, talent and luck to one that highlights interaction with others. It finds the underlying theme in effective networking, collaboration, influence, negotiation, and leadership skills. Adam Grant says that professional interactions matter. Most people operate as takers, matchers or givers. Takers are the ones who want to get as much as possible from others, matchers aim to trade evenly and givers are those rare who contribute without expecting anything in return. These styles have a dramatic impact on success. Although some givers get exploited and burn out, the rest achieve extraordinary results across a wide range of industries.
This book teaches the following:
what defines a giver, matcher and a taker
how our reciprocity style affects our networking
how our reciprocity style influences our ability to collaborate and be creative
the power in powerless communication
Social scientists have discovered that people differ in their preferences for reciprocity - the desired mix of taking and giving. Takers have a distinctive signature - often taking more than giving and tilting reciprocity to their advantage. They take the world to be competitive and in order to be better than others, they self-promote and make sure they get plenty of credits for their benefits. The opposite of a taker is a giver. Unlike takers who are self-focused, givers are other-focused, paying more attention to what other people need from them.  These two groups differ in their attitudes and actions towards other people. A taker will help others strategically when the benefits outweigh the personal costs. A giver will help whenever the benefits to others outweigh the personal costs.
A few of us are also in the middle unlike these two ends of the spectrum. We become the matchers striving to preserve an equal balance of giving and getting. Matchers operate on the principle of fairness. They protect themselves by seeking reciprocity and the relationships are governed by even exchange of favors. Giving taking and matching are three fundamental styles of social interaction.
While all three categories have their advantages and disadvantages, the givers are the ones with higher risk and rewards.
When givers succeed, it spreads and cascades. When takers win, there's usually someone else who loses.
Takers are often met with guarded interaction and withheld trust and help. To avoid this, many takers disguise themselves as givers or matchers. Luckily takers leak clues or more precisely 'lek' clues.  'lekking' refers to a ritual in which males show off their desirability as mates. In CEO kingdom, takers do a dance that looks remarkably similar.
Networks have become more transparent which lets us observe reputation and lekking.
We take  a closer look at Reciprocity next. Reciprocity is a powerful norm but with two downsides - first, people on the receiving end may feel manipulated and second it may form closed groups. Matchers for instance are vulnerable to the latter where previously burned bridges may skew their networking. As these disadvantages of strict reciprocity accrue over time, they can limit both the quantity and quality of networks that takers and matchers develop.
Reciprocity can be improved with a dimension of creativity and takers have  a knack for generating creative ideas and carrying them in the face of opposition because they are confident about themselves. Givers are also creative and we can gain a rich appreciation by studying the habits in collaboration.
In western culture, we extoll independence as a symbol of strength and collaboration as a sign of weakness. Takers demonstrate this as they see themselves superior to and separate from others. Givers reject the notion that interdependence is  a sign of weakness. A defining feature of how givers collaborate is they take on tasks that are in the groups best interests. In fact across a variety of industries and sizes, studies have shown that the more giving the employees are the better the quality of the products and services. This is referred to as expedition behavior - a term coined by National Outdoor leadership School. Contrast this with the responsibility bias. When partners overestimate their own contributions, it is known as the responsibility bias and takers demonstrate this.

Saturday, July 18, 2015

Today we complete the review of the book "Triggers". We were discussing Active questions and AIWATT principle. We also mentioned we do not get better without structure. Structure helps us gain control because it provides guard rails. For example, if we have only five minutes to speak, we make our case with a new found concision.  Similarly we need help when we are least likely to get it. This is in reference to situations which is not on our calendar. Those unguarded interpersonal moments etc. or the surprises we encounter. In the run up to a boring meeting, we might be sending signals that we are not interested leaving ourselves open to the environment. Instead if we were to realize that we will test ourselves with questions on whether we made a positive difference at the end of the meeting, we may behave differently.
Behavioral change has no absolutes.  The best we can hope for is a consistency in our effort -  a persistence of striving that makes other people more charitable about our shortcomings. Its when the striving stops, when we begin to throw ourselves on "good enough".  The risk of this attitude is that we can land ourselves in we disappoint people or create distress. There are a few environments that trigger a "good enough" attitude. These are 1) when our motivation is marginal - this is usually mitigated by either owning the task or not taking it up. 2) when we are working pro bono- where we think something is better than nothing. People forget promises and only the performance.
3) when we behave like amateurs where we are good at one thing but ignore to be good at another thing and 4) when we have a compliance issue such as when we flout rules because we become lazy.
The impetus behind these conscious decisions is to keep thinking about the environment pro-actively in the context of our desires. Then we overcome the triggers
The less we blame our environment the more tools we find. The engaging questions is one way to focus the mind and measure how we are doinvg. The other two objectives are to remain alert to our environment. The second objective is engagement.
When we embrace awareness and engagement, we can appreciate all the triggers. This completes our review of triggers.
I want to end this book review with a slightly different theme. When the going gets tough and you would rather take it out, by all means find an entry room and a pillow and go for it. The world will be unrelenting because they are not you. If you can take time for yourself, please do.

#codingexercise

int gcd(int a, int b)

{

// Euclid

 if (b == 0)

 {

     return a;

 }

 else

 {

     return gcd(b, a mod b);
}
}

#codingexercise
Double
GetNthRootProductOddRaisedPDividedQAndEvenRaisedPTimesQ (Double [] A,Double  p, Double q)

{

If ( A== null) return 0;

Return A.NthRootProductOddRaisedPDividedQAndEvenRaisedPTimesQ(p, q);

}



Friday, July 17, 2015

Today we continue reading the book triggers. We were discussing how environment tends to bring out the behaviour we don't intend to put on and how we can overcome it with active questions. The power of active questions has been studied on a set of participants where each one of them strive to answer six questions for positive thinking each day. There was an overwhelming response that it worked. A question that begins with 'Did I do my best to ...' triggers trying which changes everything. These questions for behavior change list can be anything we want. The objective for many people include health, family, relationships, money, enlightenment, and discipline. At the start, we may want to hit upon many improvements but the secret power of daily self questioning is that we either abandon our goals or we push ourselves into action.
The daily questions should be scored and reported to someone. That someone is a coach. A coach is a followup mechanism that instills accountability. Eventually we become our own coach

AIWATT is a principle recommended by the book based on the above discussion. It will reduce your daily volume of stress, conflict, debate and wasted time. It stands for Am I willing at this time to make the required investment to make a positive change on this topic ?

Like the physician's principle it requires you first to do no harm. It is a delaying mechanism and it should be deployed in the interval between the trigger and the behavior. It gives us time to consider a more positive response.

"Am  I willing" implies that we have a choice. "At this time" reminds us that it is about the present.
The only question is whether we are ready to engage in the efforts and spend some time.
The time we spend on topics where we can't make a positive difference is stolen from topics where we can.

More structure Is always helpful. Especially when we think I need help with this.

#codingexercise
List <int> GetFactors (int n)
{
Var ret = new List <int>();
// Pollard
Int I = 1;
Var r = new Random  ();
Int x = r.Next (n-1);
Int y = x;
Int k = 2;
For (;;)
{
I = I +1;
x = (x × x -1) % n;
D = gcd (y-x, n);
If d != 1 and d != n
     Ret.Add (d);
If ( I == k)
{
Y = x;
K = 2k;
}
If ( I > n )
     Break;
}
Return ret;
}

Thursday, July 16, 2015

We continue with our discussion of the book titled "Triggers". Triggers are often attributed to Environments.  In other words, we enter an environment can bring out the good and the bad. For e.g., when we overspend in a mall, we let our environment take us over.  or perhaps a better example of getting sleep. where we understand how much we need and we think we are in control yet we indulge in bedtime procrastination.  Similarly the environment that is most concerning is situational. Its one with  simple dynamic - a changing environment changes us.
The book asks what if we could control our environment such that the feedback loop only brings out our best. or this we focus on the behavioral trigger that can be encouraging or discouraging, productive or counterproductive. These are the ones that express the timeless tension between what we want and what we need. Encouraging triggers lead us towards what we want and productive triggers lead us towards what we need.
The book goes further to describe how these triggers work. The effect of trigger on behavior is described with the ABC model - Antecedent, Behavior, Consequence.  This is usually well understood in children. In adults there are three eye-blink movements - first impulse, then awareness and then a choice. What choice we make is generally dependent on whether we are paying attention.
How do we try to break this cycle depends on a few things. Can we try to ask active questions ? The act of self-questioning because its easy to do and it changes everything.
#codingexercise
If we can represent the members of a Ninja school with hierarchical representation of master and students, find the Ninjas of the same generation.
We represent the hierarchical data as tree and print the solution as trees.
List<Node> GetSameGenNinjas(Node root, int level)
{
if (root == NULL || level == 0) return root;
var q = new Queue();
var ret = new List<Node>();
q.Enqueue(root);
q.Enqueue(NULL); // level marker
int count == 0;
while (Q.Count > 1)
{
   Node cur = Q.Dequeue();
   if (cur == NULL)
{
   q.Enqueue(NULL);
   count++;
   if (count > level) return ret;
   ret = new List<Node>();
}
else
{
    ret.Add(cur);
    for (Node n in cur.children())
        Q.Enqueue(n);
}
}
if (level == count) return ret;
return NULL;
}

Wednesday, July 15, 2015

Today we start the review of a book called Triggers by Marshall Goldsmith. This is about how we react to stimuli that is against the nature of what we want to be to our spouse, friends and colleagues. We all get irritated or flustered at times. For example our temper may accelerate from zero to sixty when someone cuts us off on the road. Though the situation may seem out of control, how we respond is in our hands. This book teaches the following:
the most common belief triggers that keep us from changing
to identify our triggers and to use active questions to counter them
the power of the environment to influence behavior and the importance of the structure to change behavior
why a good enough attitude can harm interpersonal relationships

The book starts off with some facts of behavioral change:
1. Meaningful behavior change is very hard to do. Its hard to initiate behavioral change, even harder to stay the course, hardest of all to make the change stick.
There are usually three difficulties:
1. We can't admit that we need to change
2. we do not appreciate inertia's power over us. we prefer to do nothing.
3. we don't know how to execute the change.

2. No one can make us change unless we truly want to change. Change has to come from within.
If we want to be a better partner at home or a better manager at work, we not only have to change our ways but we have to get some buy-in from our partner or co-workers. Everyone around us has to recognize that we are changing.

There are belief triggers that stop behavioral change. We use these beliefs as articles of faith to justify our inaction and then wish away the result. These are called belief triggers and they are:
If i understand, I will do.
I have willpower and won't give in to temptation
Today is a special day and
At least I'm better than ...
I shouldn't need help and structure.
I won't get tired and my enthusiasm will not fade.
I have all the time in the world.
I won't get distracted and nothing unexpected will occur.
An epiphany will suddenly change my life
My change will be permanent and I will never have to worry again.
My elimination of old problems will not bring on new problems.
My efforts will be fairly rewarded.
No one is paying attention to me
If I change I'm not authentic ...
I have the wisdom to assess my own behavior...
#codingexercise
#interviewquestion
Given a continuous stream of alphabets determine if we have a palindrome or not. The stream is sending one character at a time.
The key to solving this is to keep track of the count of each character seen.
If the length of the string is even, then each character should appear a multiple of two times.
Else there can be at most one character with an odd count of 1

Bool isPalindrome ( stream s)
{
    var h = new Hashtable ();
    Char c = s.Read ();
    While ( c != EOF)
    {
       If (h.keys.contains (c)) {
            h [c] += 1;
       }
       Else {
             h.Add (c);
       }
       If (h.Values.Sum () %2 == 0)
        {
            Foreach  (int val in Values) {
               If (val % 2 != 0) {
                     Return false;
               }
            }
}
else
{
Int count = 0;
Foreach  (int val in Values) {

               If (val % 2 != 0) {

                     count += 1;

               }
               if (count > 1)
                     return false;
}
    }
return true;
}


#codingexercise
#interviewquestion
Given a board like Othello, flip the coins in horizontal and vertical directions on a move.
void flip (ref int[,] board, int x, int y, int color)
{
    int i = x-1;
    while (i > 0){
       if (board[i,y] == color)
          for (int k = i+1; k < x; k++)
             board[k,y] = color;
        i--;
     }

     i = x+1;
     while (i < N){
       if (board[i,y] == color)
          for (int k = x+1; k < i; k++)
             board[k,y] = color;
        i++;
     }

    int j = y-1;
    while (j > 0){
       if (board[x,j] == color)
          for (int k = j+1; k < y; k++)
             board[x,k] = color;
        j--;
     }

     j = y+1;
     while (j < N){
       if (board[x,j] == color)
          for (int k = y+1; k < j; k++)
             board[x.k] = color;
        j++;
     }

}