Sunday, November 4, 2012

वो रुला कर हँस न पाया देर तक
 जब मैं रो कर मुस्कुराया देर तक

भूलना चाहा कभी उसको अगर
और भी वो याद आया देर तक

ख़ुद ब ख़ुद बे-साख्ता मैं हंस पड़ा
उसने इस दर्जा रुलाया देर तक

भूखे बच्चों की तसल्ली के लिए
माँ ने फिर पानी पकाया देर तक

गुनगुनाता जा रहा था इक फक़ीर
धूप रहती है न छाया देर तक

कल अन्धेरी रात में मेरी तरह
एक जुगनू जगमगाया देर तक

-नवाज़ देवबंदी

Friday, October 26, 2012

An inspiring poem by  A. E. Housman, beautifully describing the human nature to leave some thing behind to remind the world of his existence.

Smooth between sea and land
Is laid the yellow sand,
And here through summer days
The seed of Adam plays.

Here the child comes to found
His unremaining mound,
And the grown lad to score
Two names upon the shore.

Here, on the level sand,
Between the sea and land,
What shall I build or write
Against the fall of night?

Tell me of runes to grave
That hold the bursting wave,
Or bastions to design
For longer date than mine.

Shall it be Troy or Rome
I fence against the foam
Or my own name, to stay
When I depart for aye?

Nothing: too near at hand
Planing the figured sand,
Effacing clean and fast
Cities not built to last
And charms devised in vain,
Pours the confounding main.

by A. E. Housman

Friday, June 29, 2012

Xboard Font issue on ubuntu

If you are trying to install xboard chess on Ubuntu, it crashes on start giving the following error:

xboard: no fonts match pattern -*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*

The issue can be resolved by following the steps given below:

1. Install 100dpi font:
sudo apt-get install xfonts-100dpi

2.  Check the font path in xset
 xset q

3.  Add the font path of 100dpi in xset
 xset fp+ /usr/share/fonts/X11/100dpi


Monday, January 16, 2012

A program to check if a binary tree is Binary Search Tree

The basic theory behind this implementation is that the inorder traversal of binary search tree(BST) gives elements in sorted order. So if we traverse the tree and each time we visit next element we get some higher value then we can conclude that the give binary tree is a BST.

bool isBst(node* r)
{
static int no = INT_MAX +1;

if(r == NULL)
return true;
else
{
if(!isBst(r ->left))
return false;
if(r->data > no)
no = r->data;
else
return false;
if(!isBst(r ->right))
return false;
}
return true;
}

Sunday, January 15, 2012

Linear solution of Maximum subarray problem

Maximum subarray problem
Find the contiguous subarray within a one-dimensional array of numbers (containing both positive and negative numbers) which has the largest sum.

#include
using namespace std;
int main()
{
int a[] = {-2,1,-3,4,-1,2,1,-5,4};
int j =0;
int sum = 0, max = 0, str,end,next;
while(j<9) { sum += a[j]; if(sum<0) { sum = 0; next = j+1; } if(sum>max)
{
str = next;
end = j;
max = sum;
}
++j;
}
cout<
cout<<<", "<<
return 0;
}