## Tuesday, November 25, 2014

### Code to generate all possible combinations of balanced parentheses (equal to Catalan number) using recursion

Earlier, I thought that Catalan numbers were limited to my CS lab assignment only, but when I searched for it and looked for further details of it on wiki, I was fascinated by its applications in mathematics. I would write about it later when I understand those concepts to make it clear for others.

But right now, I am writing this post because I got an assignment in my DS lab and they wanted me to do this : given a number n,  print all the possible combinations of balanced parentheses, the total number of which would be ( for now, let us assume mysteriously ) equal to  the Catalan number, and yeah that too using recursion.

Here, n represents pairs of parentheses.
For example, n=1  =>  ()
n=2  =>  () ()

I hope this makes the question a bit clear before going for the code part.

I searched for the program on the net after spending a few hours on it, but to no rescue. Every single code here was using an explicit stack. So, I decided that I would post once I code it, and see here I am. I would like to explain the code, and would surely do it someday. But, for now I am just pasting the code so that, if in any confusion or problem, you can have a look at it, and if someone is truly interested, can also understand it. I would update it with the explanation part in the near future. Till then, have fun time breaking the code and building your own!!

#include<stdio.h>
#include<string.h>
int flag=0;    // I needed this, you will understand this if you go through the program

int balanced(char *a, int n, int i, int count1, int count2);
void catalan(char *a, int n, int i, char ch);

int main()
{
printf("how many pair of parentheses do you want : ");
int n;
scanf("%d",&n);
n=n*2;

char a[n];

catalan(a,n,0,'(');       // calling the Catalan function
return 0;
}

int balanced(char *a, int n, int i, int count1, int count2)
{
// in this function, I am checking whether the generated pair is balanced or not
//i assigned -1 to '(' and +1 to ')'

if(i<n)
{
if(*(a+i)=='(')
{
count1++;
return  -1 + balanced(a,n,++i,count1,count2);
}
else if(*(a+i)==')')
{
count2++;
// if closing braces are more, it can never be balanced, and there we need a global variable
if(count2>count1)   flag=1;
return 1 + balanced(a,n,++i,count1,count2);
}}
else
return 0;
}

void catalan(char *a, int n, int i, char ch)
{
static int k=0;             // needed it, see below
if(i<n)
{
*(a+i)=ch;
catalan(a,n,(i+1),'(');
catalan(a,n,(i+1),')');
}
k++;
// if the below condition for k is not taken, we will get duplicates for every pair
// reason -> have a look at the recursive conditions, the answer lies there
if(i==n && k%2!=0)
{
flag=0;
int result=balanced(a,n,0,0,0);

if(result==0 && flag==0)
{
int j=0;
while(j<n)
{ printf("%c",*(a+j));
j++;
}
printf("\n");
}
}
return;
}

## Wednesday, November 19, 2014

### My bill in the Youth parliament session "Educated India Enable India - Quality Education for All" organised in my college

Day before yesterday, a Youth parliament session was organised in my college and I fortunately got an opportunity to participate in it and I made it to the top among all other students, giving me a chance to visit the Indian Parliament the next summer :D  I would write a post regarding my experience with college parliament session in the near future and would update here with the link.

But today I was asked to give a digital version of my bill along with answers to a few questions so that they can get it published in the newspaper :D  Okay, once published I would surely attach a news pic with this post. But till then, I thought it would be a good idea to post my ideas on the blog as such.

1. What motivated you to participate in the Youth parliament session “Educated India Enable India - Quality Education for All” ?

Being a student was more than enough to motivate me to attend this session because it’s when you are a part of the system, you not only see but feel the drawbacks of the system. Our education system suffers from a lot of issues like the lack of accessibility of the education to all, the low quality of teaching, or the persistent job oriented mentality of the society.

A dream, a vision of mine to bring about the required changes and reforms, not just on papers but in real life, it’s this thing that motivated me to participate in this session.

1. Suggest the two most important steps according to you, need to be taken to take Indian Higher Education system to International standards.

First and foremost that I consider is to improve the quality of teaching, which is a must to make the process of learning enjoyable. Today, most of the teachers don’t feel accountable for the performance of their students. The reason is also quite clear, there is no incentive system to motivate the teachers to perform better.
This further leads us to a society whether there is no passion among the youth to pursue a career in teaching. Top performing countries in education across the globe recruit their teachers from top 5-10% of their best universities. But here if you can’t make anything out of your life, you become a teacher.
A change in this mentality has become the need of the time and it can be brought by implementing the incentive system, a new system design to recruit the teachers with the principal focus on quality, and to make the teaching more creative and less robotic, with less focus on a sequence of dull memorised steps and more focus on applications, reason and logic.

Second step that I would recommend is to provide education to the poor kids who are often neglected in this system or considered of very little importance, and yet they have shown time and again that they are equally brilliant as anyone who goes on to take the benefits of our “elite education system”. This poor India has to put up with very poor government schools in the deep interior. Majority of this poor India drops out of school before they get to the 10th grade. If our country could manage to provide them with the same level of education that we get, India would definitely not be at this state of development.

1. Propose a bill that you wish to present in the youth parliament.

My bill tries to bring something that almost most of our schools lack and that is encouraging creative and innovative thinking among its students.  I have named my bill “YOUTH ENTREPRENEURSHIP BILL
The bill proposes the integration of entrepreneurship in a creative way in our classrooms so that people can go on to pursue their dreams, to do what they really wanted to do in their life.
The bill provides the steps for the same-
1. providing more active and vocational courses where education doesn’t look like a burden to them but rather they go on to actively participate even in their least favourite subjects. Taking the example of maths which unfortunately happen to be one of the least liked subject among the students, maths problems should be motivated not just through the sciences, but also through the arts: puzzles, toys, magic, poetry, music- these should all form a key part of the mathematics.
2. a regular visit to different NGOs to see what all work they are doing and getting some inspiration from them, a visit to different villages to realize that life is not that good what it looks like and to see the facilities that these places lack from, a visit to towns like Firozabad to feel the drawbacks of the present system, and to encourage them to present their views and what all innovative ideas they do have to better such situations, and, motivating and helping them to even implement their ideas to whatever extent it is possible and providing them the thrust to look for even more such ideas and their effective implementations.

The reason for this bill goes on with the theme “Educated India, Enable India”. We do have the people who are educated but most of their education is job-oriented and never let them ponder over the issue of building an “Enable India”. This bill of mine inspires them to think of it, it lets them broaden their vision from merely getting a job to the point of joining hands with each other to develop a stronger, talented and developed India.

## Friday, November 7, 2014

### What do 5, 13 and 563 have in common?

Well, nowadays it seems like I am getting more interested in number theory with time. I picked this one at random from Numberphile and it felt good to have one more thing in your basket -- this time the wilson's prime and the wilson's theorem. Have a look at them!!

## Friday, September 26, 2014

### Can entrepreneurship be taught in classrooms?

Yeah, it can be taught. Entrepreneur, in layman's terms, is someone with a vision supplemented with a belief that it can be achieved and a craziness to take risks to achieve that. It's all about being creative in your approach. But is that happening in our classrooms? With what all I have seen so far, it's not the case, atleast in general.

Before going any further, I would remind you of a story which everyone of us has read or listened at some point of time in our life. The story of parent bird pushing its baby out of the nest so that it can learn to fly and more importantly can become independent. The same applies here. The students should be given the chance to become independent, but instead what happens is that most of them remain dependent on their parents till the age of 21 or 22 unlike in other foreign countries. So, when the ripe time comes to give a shape to their ideas, they are just not confident enough of themselves, the reason being that they were never given a chance to make independent decisions. And thus the entrepreneur in them just remains inside and it never comes out.

This is what needs to be changed. Instead of burdening them with books of which they understand nothing, let them play with the colors, let them interact with the nature, let them produce something original, something of their own. Instead of making them memorize science facts, let them build some robot of their own, let them practically understand why the density of ice is less than that of water, what causes it and what does it cause, let them practically understand that salt water conducts electricity and what all implications/applications it can have. Instead of making them memorize history dates, tell them why that particular date is important and what all lessons can we learn from that particular historical event, instead of getting stuck at the history of pre-independent India, tell them some history of post-independence too. That's also of some good value.

Oh, wait!! But we were talking of entrepreneurship? What these things have got to do with that?  Well, bear with me for a few more moments and you will get to know what these things have got in common. So why stop at science and history, the same can be said for subjects like value education, environmental education and disaster management, the subjects which are of great value in real sense but somehow have become a kind of joke in our schools seeing the way they are being taught and in fact at many of the schools they are just there for some reason that only God knows and are not being taught at all.
Focusing on the importance of these subjects, only when these little kids, these young minds are given an exposure of what problems our society is facing, what all limitations are there that we need to overcome, what's the disaster management scenario in the country, how badly the environment is getting affected and what all major implications it is having for them and to the whole world, only when they feel these things that they can become interested in a particular domain or find some really cool, creative ideas and possibility does exist that they would become passionate enough to pursue their dreams in the same field. And then you go on to call them "SOCIAL ENTREPRENEURS". But first and foremost, give them the exposure and the chance to do so!!

See what I want to say is that it starts with exposure which leads to interest and then those who are crazy enough go on to change the world. And for that we don't need to give some extra load of one more subject something which our schools would go on to say as "ENTREPRENEURSHIP EDUCATION". No, that would be totally useless considering the case of what happened with other subjects. Rather we need to change our approach towards learning. Let it be "breadth first, depth second" because only then someone can find what he is really interested in. And when they take these baby steps gradually becoming more creative in their approach or if I say "retaining the creativity" that they had as a kid for everything that surrounds them, it would help them not only to become a great entrepreneur but would serve them throughout their life, wherever they go, whatever they do.

## Monday, July 14, 2014

### my experience with dgplug summer training program so far!!

Well, some of you might be wondering what is dgplug summer training and even I was in the same state when I first noticed it. So let me first tell you what this is!! Dgplug  summer training program lets you get acquainted or ,in more refined terms, introduce you to the world of open source projects. It is Linux Users' Group of Durgapur, of which Kushal Das is the main coordinator.

So, here is how i stumbled upon this program. Actually I happened to be a little bit motivated that day and was eagerly searching on how to get started with open source projects on Quora and basically about how to contribute to GSoC. And there I found an article by Sayan and it was more than enough for me to get started in this program. Here you can refer to that answer.
http://www.quora.com/How-can-I-fully-utilize-2-months-of-summer-break-I-want-to-learn-coding-Should-I-start-with-HTML-CSS-or-go-with-Python-PHP-Django

And so how is my experience this far? Well it was sort of strange for me in the beginning because I had never heard of IRC before and hence I had no idea how to use it or even why to use it. But all that changed within a day or two, thanks to the way Kushal and others taught us those very basic things related to IRC. Also this program started on 29th of june and I read that article 2 days after that, but I didn't need to worry about that because the logs are always available there and you can easily go through them. So, while reading this article, if you are thinking whether you start or not, i would suggest you to come and start now only. There is so much to learn here and even if the program has ended, there is nothing to worry about it, as this dgplug program runs every summer for those like you and me :)

I have already been there for more than 10 days and I really learned a lot of new stuff. First of all, we were introduced to certain etiquette that we need to folow while being on IRC some of them being <eom> and !.  Then they taught me about vim and how to work on it. Vim is basically a text editor for basically a lot of purposes and one of them is writing out your code. Then I got to know about rst which earlier I had no idea of and yeah! I even created an about me page using rst.
There were also a few sessions dedicated to the sharing of experience by Sayan and Chandan Kumar on how they started in this open source culture and it was inspirational. There was a session on blogging too, the same thing I am doing now. They also told us about command line and encouraged us to read a book regarding that. It was fun learning that! I am also excited to learn about git, which I have only heard of till now. And I am more excited that after a few months I am going to be able to contribute in the same open source environment.

I think this one would surely help me understand how to contribute to open source and also get me started for the same. I am also sharing one video of Kushal Das at PyCon 2014 for it also encouraged me to get started with this program.

## Thursday, June 12, 2014

### dreaming big, working hard..

There was a time, i was failing
constantly, and not briefly
with no one to help, none bothering,
trying to understand me,
my feelings, my pain.

Maybe i wasn't working hard,
or not being dedicated or disciplined;
that's what was on everyone's lips to discard
me, my questionnaire, my hard to maintain grin.

But still believing my own rational judgement
to go on and on,
I pushed up to the limit
to fulfill the dreams that i own;

the dreams that were sown,
that were grown
mindlessly without much effort;
for the child was unaware of the discomfort
to me, my drift, my night-shift.

But it's okay to have such dream
that can shove you out of your zone
and fill you with talent to the brim,
to show the world the skills you honed.

So what if I didn't get that one,
plenty of them still reside in me
and gauging my drastic run,
I can make my shortcomings flee.

Now being dedicated, motivated, staunched, all in a row
I do know
which door to knock

## Monday, May 19, 2014

### Game Theory Tuesdays: Should Cyclists Roll Through Stop Signs? What Vox Did Not Address - Mind Your Decisions

Game Theory Tuesdays: Should Cyclists Roll Through Stop Signs? What Vox Did Not Address - Mind Your Decisions

i am new on this site but i am just loving all the articles all around there.. one should definitely give it a try.. at least those who get excited when somebody talk of Game Theory.. =D

## Friday, May 9, 2014

### Review of "Nothing Lasts Forever" by Sidney Sheldon

Well, all thanks to this novel for it added all the necessary ingredients to make my trip back home an awesome one and yep thanks to my dear friend too who suggested it to me. It was my first novel of Sidney Sheldon and ye i loved the story telling and i am already on my way for his second novel "If Tomorrow Comes" and i am sure i would love this one too.

The story has many things in it, ranging from male dominance to how bad someone's greed can be, to how hard a doctor's life is. Starting with that of male dominance, i can say that it's not of that level as described in the book knowing the fact that the book was published in 1994. Ofcourse things would have been like that only in those days. But you just can't ignore it for the present society because that stupid dominance still does exist (and more than that it's the sexist comments people do make or harass women in some way or the other)  and we all can feel it, the only thing being that the level has gone down with time, thanks to the determined efforts of the women as well as the awareness that is spreading in the society.

Then i was also lost in my thoughts while reading the daily schedule of a doctor as was described. I can for sure take some lessons from that but at the same time, such a scenario still does exist in government hospitals and that's very dangerous from two points. Firstly most of the good doctors want a good payment, so why would they work for govt. hospitals where the load is too much, when instead  they can work for private hospitals or set up their own private practice and live a luxurious life thereafter. And then you are left with doctors like Arthur Kane who can operate on your good kidney leaving you on dialysis forever.
Secondly, when a doctor works for such long hours,  he/she is surely to feel frustrated and this is not good for it leaves no time for themselves or their families and this might lead to some disastrous results as was the case with Tom Chang.

It was also inspiring to read of the childhood of Paige and especially of her father. It's natural to me to feel inspired when i read of someone like him. Even though he was a fictional character, people like him do exist and they do motivate us to do some good for the society. Then the childhood of Honey do show us the pressure of performing well in a brainy family. But it does give an insight to the case of honey traps which is surely not a good thing at all, whatever case it may be. This led to the wrong diagnosis of her patients, however we cannot blame Honey for it. A large share goes to her parents who never respected her feelings and this surely gives us the lesson that every child is born different and you can never pressurise  them for something they don't want to become, and their feelings need to be respected and they should not be mocked for their ideas for they would then never share anything with you.

Then there are people like Kat who never lived their childhood, rather it was some kind of horror for them.The words of her aunt were truly inspiring. "You can keep running and hiding and blaming the world for your problems ,or you can stand up for yourself and decide to be somebody important by knowing that you're important. First you get an image in your mind of who you want to be, child, and what you want to be. And then you go to work, becoming that person."

Not to forget Barker. People like him do exist whom we hate so much that we always wish something bad for them or atleast wish to get rid of them, the reason being their cold and arrogant nature towards us. But these are the people who want something good for us and are always there to extend their helping hand.
There were many other characters like that of Ken, who could even kill someone for his greed or Alfred, whose work didn't surprise me that much for that can happen with anyone given the circumstances.

Then, what about the title of the novel NOTHING LASTS FOREVER... I was thinking of it and the sense that it made to me was that all the three of female doctors had to go through different phases of joy and sorrow in their lives and may be that's what life is all about. Nothing is permanent out there. And if extended further, the same can be said for the relationships that we do share with different people throughout our life.

And finally the person of the novel. It's difficult one to choose,but I am more inclined towards Paige Taylor than anyone else for all her characteristics that Sheldon has shown to us. Overall a marvelous storytelling and looking forward to read more novels of him!

## Saturday, March 1, 2014

### entangled within..

entangled within my own thoughts,
trying hard to read the scribblings on the wall
asking myself what am i learning
or am i learning something even..
is this what they call education ??

feeling afraid that my mind won't have an answer for this
i posed this enigma of mine to him
out of curiosity.
but thankfully he did have an answer
So he asked me with a breath of warmth
are you in some hurry ?
I said- "No, but what's the matter";
"Well you seem to be in some hurry,
as if you need to catch any ferry..
Remember-learning is a life long process
it's less of a destination and more of a journey,
a journey of exploration,
some kind of quest for knowledge"

Seeing me all confused, he asked what happened..
i could barely speak but then told him in a bit low tone
that it all seems scrambled,
for my teachers use to tell me i am not good at learning
as i don't get good marks like others..
so i probably thought learning was about marks and appreciation
but now you say it's some kind of exploration..

My mind gave me a superb smile
for those are the foolish men who think only a little bit,
these are the ones bcoz of whom it took Galileo
so many years to come,
and forced genius Einstein to feel as a child
as if he was a failure..

"These are the ones who feel proud
to remain as parrot, and
not evolve as a human..
it's bcoz of them that our education system sucks to this extent,
but now i want you to buck whatsoever it offend..
Think of yours as an interesting voyage,
which may be disturbed by a few storms
setting up all this stupid norms..
show them all how education is taught,
and don't forget to help others, like you, out"

After all this, i felt some sense of change,
some kind of happiness all around me
and seemed as if the scribbling on the wall
became a lot more clear..
Well, it was just written out there-
for this is what learning is in real sense..."

## Monday, February 3, 2014

### Is our nationalistic identity being threatened by globalisation ??

I don't know what's bad if you are being given the choice to select between various items, so that you can purchase what you like , and more importantly what you want.

Consider a case where there is the only telecom service of BSNL and they are giving you the only option of a particular recharge.What your feeling would be like ?? =D .. or considering a more serious situation, there is an outbreak of a disease in your country and the require medicine cum technology is not available there. WHAT THEN??

Globalisation is in no way a kind of threat to our nationalistic identity. And what kind of national identity are we talking about ? Where no one knows you or would you like that people around the world know you, your work and appreciate you for that, and more importantly people get a positive thinking of your country.
Take the case of Reliance and Tata from India. They made it worldwide because of globalisation only and they are competing at their best making it sure that India holds a name in the chart.

And asking you, the reader only, what situation of the country would you like to be? Where people die of diseases and no one is out there to help them.. or people live a peaceful and disease free healthy life.And if someone is thinking of the second option, then he or she is surely in support of globalisation.
Globalisation has made the medicine available worldwide. It has helped improve the communication technologies, which make it easier to alert the relevant authorities to the outbreak of a particular disease. Disease control capacity in one part of the globe can readily be deployed to fight diseases in other parts of the world.

And one more thing, globalisation has helped us to know so many different cultures and mix with them. So many cultures and languages would have died had globalisation not been there. Take the example of  one of the primitive languages from our own country - SANSKRIT. Only a few people, excluding those who perform all the ritual kind of things, have the knowledge of this beautiful language. And they have not done anything, except a few, to spread it around the world. It is the people from the west only who are eager to know about it and they are the ones who are spreading it in the west. AND the case is not just of this language, I can take the examples of Ayurveda and Yoga too. If I go a bit further, countries like Britain and US are taking Ayurveda more seriously than our own country where it originated. And the thing is globalisation is not just spreading a language or a culture or technology, it is also helping to improve it to a good extent.

But then people go out to blame globalisation for the falling of a particular currency against dollar. So speaking of my own country, FDI has not yet been implemented to that good extent in India and the fall of Indian Rupee is not because of globalisation but due to the inefficiency of the ruling Congress government at present, which is otherwise also gonna be thrashed out in the coming up 2014 Lok Sabha elections. While the growth rate of India ,in general, is not that good, Gujarat has shown high growth rate in the same situation and NaMo is someone who is whole-heartedly in favour of sustainable globalisation and he has shown it with his governance and still not a single person in the state has lost his/her identity.Instead they are proud to belong to such a state. So loss of nationalistic identity is nowhere threatened by globalisation.

Coming to the next point, people often relate BRAIN DRAIN  with globalisation. But the case is not so.
We all know of Srinivasa Ramanujan. Had Hardy not been there, his ideas would not have spread all around the world. But that doesn't happen to everyone in the modern society. Do you want the great ideas of someone being wasted just because he is not allowed to work with like-minded people.
There are so many Indians working at CERN. Would you call it a brain drain? No.not at all ! It just shows the world what all talents do we possess and that's a good thing.
Rather there has been a process of reverse brain drain in the past few years. People of Indian origin around the world are coming back and that too with all the great experience and talent of theirs. Think of that students won't need to go to other countries for their higher studies (the improvement for this is already on the surge) or patients no more need to go anywhere else for their treatment. Isn't that great ?

So, if someone says that our nationalistic identity is being lost by globalisation, i can't help but think of some innocent child saying he won't compete or give the exams for he isn't still prepared, knowing in the heart that he would eventually fail because he knows too less and that he didn't put up all those efforts. GOOD LUCK to him then because he is neither going to learn something in that case, nor improve himself.. But then we can't let him go this way. He will be made to face the competition a few times, chances are pretty good that he will fail a few times, but then he will gradually learn to survive and not just survive but to make his mark, to make a point to this harsh society that it was never that he lacked imagination or creativity, it was just insufficient efforts on his part.. and now as he is having that, HE IS ALREADY ON THE WAY TO MARK HIS REAL IDENTITY!!