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;
}

No comments:

Post a Comment