Monday 17 September 2012

Dr Michio Kaku talks about physics:

There you go...2000 years of science in a 40 min video. Hope this gets you interested in physics and the laws that govern our universe.

Tuesday 11 September 2012

Eye of the Tiger

This is a great inspiring song. It's the theme song for Rockey III movie.
It's from Survivor group. 
Here's the video. I hope you enjoy it.


Here's some lines from the song:

...So many times, it happens too fast

You trade your passion for glory
Don't lose your grip on the dreams of the past
You must fight just to keep them alive

It's the eye of the tiger
It's the thrill of the fight
Risin' up to the challenge
Of our rival
And the last known survivor....

Friday 7 September 2012

Free .Net Programming ebooks

We have a collection of ebooks in programming, mostly .Net, and we are happy to send to anybody who wants a copy of their desired topic for free.
You only need to leave a comment with your book name, and email address and we mail it to you.

this is free, it doesn't have anything to do with on line marketing or stuff.
we couldn't come up with any other solution to publish these ebooks,
and we don't have any website whatsoever.
we don't use your email address for any other matters, which we are not really  interested in your email for any reason.

regards

Thursday 6 September 2012

How to install Gnome shell in Ubuntu 12?

Steps are so simple:
go to 'Ubuntu Software Centre' and search for 'Gnome Shell', our desired shell should be first or second one in the returned list. its name simply is 'Gnome Shell'. click it and then click 'Install'
It takes a while to finish downloading and installing. after installation finishes just log out the system and then log in to the system.
this time when you want to log in there is extra option next to your user name where you can choose your newly installed shell, and that's it.
you can also install Gnome shell using terminal by following command:

sudo apt-get install gnome-shell

There are other shells and extension as well.

Monday 3 September 2012

Removing your email account in Thunderbird

     When you set up your email account with Thunderbird all your mails can be seen by other people who have access to the system. for synchronization, it needs your password but still your old emails are on the system. to remove your account from Thunderbird:
you can go to menu  'Edit' > 'Account Settings' then it asks you for your email password, after authentication, you have an option at the button of 'Account Settings' which is "Account Action' click it and then you can choose to remove your email account form Thunderbird.

Sunday 2 September 2012

Reflection of a Binary Tree

    Reflection of binary tree means if you have a binary tree like following:

                     a                                                                                 a
                  /      \                              becomes like this                  /      \
                b         c                                                                      c        b
              /    \      /   \                                                                  /    \     /   \
            d     e    f     g                                                                g     f   e    d

                       
There are 2 approaches to this problem 1- using stack 2- recursively swap sub trees
I explain both and give Java code for second approach.

1.Using Stack

     If you have recursion, you almost always can do the same job using stack. steps to produce reflection of a binary tree is:

1- Push the node in the stack
2- Pop the node from stack and if it has childes swap them
3- Push the left child and right child after swap
4- do theses steps until stack becomes empty which means you visited all nodes

example:
stack: push 'a'
pop 'a' then swap 'b' and 'c'.

stack: push 'c'. push 'b'.
pop 'b' then swap it childes, 'e' and 'd'

stack: push 'd'. push 'e'
pop 'e' which doesn't have children so return.
pop 'd' which doesn't have children so return.
stack : only contains 'c' now
continue...
pop 'c' and swap its children.
stack: push 'g'. push 'f''

pop 'f'' which doesn't have children so return.
pop 'g' which doesn't have children so return.
stack is empty now so finish.

2- Recursive method

     For operations on binary tree most of the times using recursion is a good idea.
with recursion, reflection happens in place which means the original tree replace with reflected tree.recursion is shorter than first method.
imagine you have method called reflect(Node<E> node)
which accept Node<E> of the binary tree. we call this method in our caller method with root of binary tree.
steps are:

1-if root is empty return
2- call reflect for left sub tree
3- call reflect for right sub tree
4- swap left and right sub trees using temp variable...temp is the same type of node.

Java code:
Testing:
To test operation on binary tree, the best approach in my opinion is to use Graphvis website which shows you visual output based on your input. you can write a method to traverse your tree after and before reflection and generate a  Graphvis  dot file or its accepted input data, then you can use  Graphvis  to see the output is what it is supposed to be.
I give a Java code for generating dot output to use in  Graphvis  .
output is in String format, however you can write the output to a .dot file and then load it on  Graphvis  website.

Java code for generating Graphvis .dot data:


p.s: When using this generator you should add the following line before the actual data inside the curly braces to give you right visual output:    graph [ordering="out"];

p.s.s: You can also use queue instead of stack.