Tree traversal – Easy way to remember

Tree is one of the most outright hierarchical data structure available. And always remembering the traversal has been a little confusing (At least for me). Root first or Left first or Right First?

While people can remember easily like say start with Root,Left,Right and then move Root step right fir every order it will be easy. Say below.

Pre-Order – Root, Left, Right

In-Order – Left, Root, Right

Post-Order – Left, Right, Root

While the above is easy to comprehend when given a tree we get a little confused. Below is a diagram that will explain you to remember easily. As soon as u see the tree you can write the sequence right away.

Tree traversals

Above image is self explanatory, still I would comment a little.

Pre-Order – Keep marking the arrow from Root then extreme left and then right. Unfortunately I cannot think of a key word that you can associate but the simple jump from one node to other in that fashion you can quickly write it.

In-Order: Remember the free fall, mark arrows downwards, all tree leafs are falling. Then you print in-order. Just remember this is a very important order widely used. Especially in BST where in order to print a number in sorted order. We use In order.

Post-Order: Leaf break or Leaf cutting, start removing the leaf one by one in the sequence of Left then Right and then finally Root you get the post order sequence.

You may check this in video as well, but that’s in a Regional language Hindi.

Sponsored Post Learn from the experts: Create a successful blog with our brand new courseThe Blog is excited to announce our newest offering: a course just for beginning bloggers where you’ll learn everything you need to know about blogging from the most trusted experts in the industry. We have helped millions of blogs get up and running, we know what works, and we want you to to know everything we know. This course provides all the fundamental skills and inspiration you need to get your blog started, an interactive community forum, and content updated annually.

Grep in Solaris

Many of us know the command to grep in Linux based systems, few lines before and after we can use the -A and -B to say how many lines before and after one wants to grep.

Say, grep -B 10 -A 10 <Search string> <Filename>.txt will search the string and will also display 10 lines before and 10 lines after in the files.

Coming to Solaris we cannot use the above before and after and we need to deal a little bit programmatic.

Say below.

nawk ‘c–>0;$0~s{if(b)for(c=b+1;c>1;c–)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}’ b=<Number of lines before> a=<Number of lines after> s=”<Search string>” <File_name>.* >> <File_results_to_be_saved>.txt

Bhuvan – Far from Google Earth

Ever heard of a regional level Google Earth implementation (Sorry to compare with Google). Yes there is one called Bhuvan from ISRO, India.

It’s a bit OK, especially because of the granularity in Maps, a good initiative to work on Regional Maps by ISRO. We have 2D imagery, 3D imagery, pretty reasonable zoom.

Watch out for more on

There is also an android app for the same. Get it directly from below.

It still needs a lot of improvement, well this is what we say when we match an international product like Google 😉

Play in Google’s playground – For Beginners using Google API

Quite lately, for the past few years I have been obsessed with Google. Well who doesn’t like Google and its tiny gizmo projects. Most of the techies like it. Working in Google’s API is quite challenging sometimes. However most of the API’s Google provide are very interesting and it’s very easy to use. Say if you are designing a website we deal with certain necessary functions to keep. For those these Google API’s will help in a great deal.

Say you need to load feeds in your website, you have google.feeds.Feed API which can fetch the feeds and display for you.

If you need to implement a search within your website, then go for APIs, there are many sub classes which can really help you out in what content you are allowing your users to search.

Calendars, Language specific translations, Virtual key boards, Maps, YouTube video and its player customizing functions. Authentication using Google Authentication and so on.

It also offers many functions for Visualization. In Google Visualization API things are made very simple. See below, an example where a pie-chart was generated.


Interactive charts, quite interactive isn’t it? Want to see the code how simple it is?

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    [‘Task’, ‘Hours per Day’],
    [‘Work’, 11],
    [‘Eat’, 2],
    [‘Commute’, 2],
    [‘Watch TV’, 2],
    [‘Sleep’, 7]

  // Create and draw the visualization.
  new google.visualization.PieChart(document.getElementById(‘visualization’)).
      draw(data, {title:“So, how was your day?”});

There are also few visualizations that are complex in nature, by passing dynamic data and generating on the fly etc.

So Google API’s offer you a comprehensive list of API’s to play around and you can add in your project any time. Also Google gives a sample page where you can write your code, run and even debug and see whats happening. Cool isn’t it?

Check out more on the below link and keep watching that space for new additions on API’s.

So people interested can play in Google’s play ground. Happy coding 🙂

Note: The code pasted above is from Google Playground sample code. I don’t own them.