Saturday, September 22, 2007

Dustbin..

Hey..

Dont blame upon your eyes, yes you are watching the blog on "Dustbin"(ji haan KACHRAA-PETI)... I know, it's little surprising to see a blog on such a topic, I dont know if you have watched the similar discussion somewhere by someone! None can write on it until or unless one knows its importance. Importance of dustbin, again a surprise!

See, Dustbin is something which collects the useless stuffs or say garbage. What if there wouldn't have been such dustbins!

Think, yes think about the situation then..There won't be a single place where you can put the wastes, such garbage or waste will be spreading everywhere. Then not a single place will remained worth living, even before putting a step ahead people will have to think a lot to decide where to put it!

Seriously it will become impossible to imagine such situation! Because it's something which helps us to improve the way we live, to manage the things by removing the stuffs which are not usable. In other words, It removes the dirt from our life and makes it dirt-free, clean and healthy!


In computer science, there are so many languages which implements the same concepts through "GARBAGE COLLECTOR", infact on a simple configured computer has a "RECYCLE BIN". See, even such big scientists and research-doers prove its importance globally!

There is something to learn from it, so kind it is!It takes the waste from others and let them live freely. If we cant remove the unwanted (and unusable) things of others, how can we expect a dustbin to collect our waste even it's doing the same thing...

Do the fights solve the matter?

Hi friends!

You would have often seen the people having fights with each other upon the several big or small issues. This blog is something to do with this only!

I dont understand why and how people get into it? Surely there would have been enough trust and support for each other when they started the relation, then where has that trust and support gone at that time??

Every issue can be solved by simply having serious as well as honest talk to each other. Almost in every case there happens a single misunderstanding which can be removed if involved people wish to do the same. Even the big wars have successfully stopped by applying the same funda and I dont think that situation becomes so worst among such people generally?

People destroy their sweet relations only because of just fights. If they really want to avoid it, they should think properly about he whole matter and let the other involved person present his/her thinking behind the same! Think about the sweetness and smoothness of the relation, think of the good past memories, surely It wont led you to fight thus it helps you to save the relation...

The fights also disturb the balance of your mind, you cant even think the things in the way you generally do.. So you can imagine the side effects of such nonsense of fall into such destructive stupid fights!

I would like to advise you readers please do not let you involve into such worthless fights for the sake of your relation as well as for your mental peace..

Tuesday, September 18, 2007

Sunday, that wasn't like a SUNDAY..

It was 10:00 am in the morning of sunday; 16th september 2007 but that was not like other sundays! We (the 2007 batch NCSTians) were watching each other's faces while sitting in the lecture hall for the extra session of DS which was going to be start in a while by our Raman Sir..The irony of the title is also true for him, as he too was sacrificing his sunday!

But the lecture was really a GOLDEN GLIMPSE towards what we learnt so far in that subject including some extra applications as well as important do's and don'ts.. And this time my blog is dedicated to that lecture, I mean I m trying to cover a little part of it (little because what I got was while several iterative rounds of sleeping-awakening)! Oh wait, dont estimate that I am trying to say that lecture was boring, THAT WAS AWESOME but the SUNDAY WAS ON ITS FULL and we generally used to spend our time in some other manner on sundays, if that session hadn't there!

So, Raman Sir is requested to forgive me if I go wrong at some point in it and to rectify those mistakes so that people; like me can take benefits of this blog. Sorry to non-NCSTian friends this time for being specific about NCST!

Let me pray to God and allow me to start:-

Variable selection in recursion:

Actually Recursion refers to a function calling itself. Whenever we need to check the status of a variable after each and every pass, we declare it as GLOBAL variable. If the need of the variable is just satisfied after each pass then we declare it LOCAL.

DFS & BFS:

It refers to Depth First Search and Breadth First Search. In DFS (if we talk about in terms of DS like TREE), as the name suggests, we first go to the deep of that node explore its children and then we explore it and its siblings. We implement it through STACKS..

While in BFS, we first explore the siblings of a node and after that we do the saem to its children. We can implement it by the help of QUEUE.

Application of Stack in Postfix notation:

Suppose we have an expression in postfix notation: "(2 3 + 5 6 * -)" then to solve such kind of expression we take the help of stacks. First the operands(2,3 etc.) will be pushed into stack. We popped two operands( or one operand) as soon as a binary operator(+, - etc.) (or unary operator like ++,-- etc)comes!Then push the result into the stack.

For example::-

Push 2,3 first. As + comes, both pop up and added which results into 5 into stack. then push 5,6. As * comes pop 5,6 and push the result 30 into the stack, as - appears pop those remained values 5,30 and perform the -.Which results into Final value of (-25).

Queue and Circular Queue:

As we know, queue can be implemented only with the help of two varibles front and rear while for the implementation of Circular queue we need to have these variables with some other like size, count, apart from it we also perform modulus operation for overcoming the limitation of normal queue which comes into picture when front becomes equal to rear and it shows the queuefull exception while it is totally empty.

We can also implement it without those extra variable but tehn code becomes little complex. In that case we have to check whether front crosses the rear(for queueEmpty exception) or the rear crosses the front(for queueFull exception).

Deletion in tree:

The hardest operation in tree, I suppose is deletion. While doing it, we should chech the following steps first:

  • Determine Node to be deleted is the leftnode or the rightnode of its parent.(say LCorRC)

  • When leaf is to be deleted-First findnode. then findparent, check LCorRC. Then delete it.

  • When Node to be deleted has only one child-First findnode. then findparent, check LCorRC. Finally delete it by attaching LC (or RC which is not nul) to its parent!

  • When Node to deleted has two children- Well after performing above operations I think its not very difficult to do this operation, actaully I ve to cover up all other stuffs so IM LEAVING THIS TO YOU PEOPLE to consult from any good book.(This is the best way to GET RID OF IT...hahahahahaha)

Let me provide a scratch of code to elaborate the following:-

Tree to array conversion:

It's supposed that you already have the class Node and int arr[].
public void t2a(node n,int p)
{
if(n!=null)
{
arr[p]=n.data;
t2a(n.left,2p);
t2a(n.right,2p+1);
}
}

Find the node in Binary search tree & in Binary tree:
//IN BINRAY SEARCH TREE..
public Node find( Node n, int i)
{
if(n!=null)
{
if(n.data==i)
return n;
else if(n.data>i)
return find(n.left,i);
else
return find(n.right,i);
}
return null;
}
//IN BINARY TREE..
public Node find(Node n, int i)
{
if(n!=null)
{
if(n.data==i)
return n;
Node temp=find(n.left,i);
if(temp!=null)
return temp;

return find(n.right,i);

}
}

for further queries click onto:::--http://gnyan.ncb.ernet.in/~dsalfac/