Saturday, October 20, 2012

In layman's terms, what are the major programming languages, and what are they used for?

OK, this is going to be a little bit un-PC, but what the hell.
PHP is your teenage sweetheart, the girl you first awkwardly fumbled around with that one summer. Just don't try and start a more serious relationship - this girl has serious issues.
Perl is PHP's older sister. She might be a bit old for you, but she was pretty popular back in the 90s. She's looking pretty ugly and scarred now, so you don't hear from her too much.
Ruby is the cool kid of the scripting family. When you first saw her, she took your breath away with her beauty. She was fun, too. At the time she seemed a bit slow and ditzy - though she's matured a lot in the last few years.
Python is Ruby's sensible (and slightly more boring) sister.
Java is a successful career woman. What she lacks in raw intelligence she makes up for in dress - always turned out in immaculateCamelCase, sure to impress the enterprise customers. You might feel like she's the sensible type you should settle down with. Just prepare for years of "NO THAT DOESNT GO THERE GOD YOU ALWAYS USE THE WRONG TYPE AND YOU MISSED A SEMICOLON" nagging.
C++ is Java's cousin. Similar to Java in many ways, the main difference being she grew up in a more innocent time and doesn't believe in condoms/automatic memory management, so be cautious.
is C++'s mom. Mention her name to some old grey beard hackers and they're sure to reminisce with a twinkle in their eye.
Objective C is another member of the C family. She joined that weird church a while back, and won't date anyone outside of it.
Haskell, Clojure, Scheme and their friends are those hipster, arty, intellectual girls you probably spent a blissful college summer with a few years ago. The first girls who really challenged you. Of course, it could never have become something more serious (you tell yourself). Though you'll always be left asking "what if?"
You might be put off C# due to her family's reputation. But they've gone legit, the last few years, they tell you. Once you're one of us, you're one of us, you hear? You need a database? Her brother MSSQL will hook you up. Need a place to stay? Heck, her daddy will even buy you your own mansion on Azure avenue. What's that, you're having second thoughts about all these overly friendly relatives? No, you can never leave. You're part of the family, now, ya hear?
Javascript - hey, wasn't that the girl you first kissed, way before even PHP came on the scene? I wonder what she's doing now. I hear her career's really taken off in the last few years. Would be cool to catch up some time, if only for old time's sake... (You catch sight of her, dressed head to toe in designer jQuery)... wow,somebody grew into a beautiful swan...

The illustrated guide to a Ph.D.


what a Ph.D. is.


It's hard to describe it in words.
So, I use pictures.
Read below for the illustrated guide to a Ph.D.


Imagine a circle that contains all of human knowledge:
By the time you finish elementary school, you know a little:
By the time you finish high school, you know a bit more:
With a bachelor's degree, you gain a specialty:
A master's degree deepens that specialty:
Reading research papers takes you to the edge of human knowledge:
Once you're at the boundary, you focus:
You push at the boundary for a few years:
Until one day, the boundary gives way:
And, that dent you've made is called a Ph.D.:
Of course, the world looks different to you now:
So, don't forget the bigger picture:

Keep pushing.

Resources

http://matt.might.net/articles/phd-school-in-pictures/

Saturday, September 29, 2012

Trie!! it's fun


 #include< iostream>
#include< stdio.h>
#include< string.h>
#define NOT_FOUND 0
#define FOUND 1
using namespace std;

struct trie_node
{
       int words;
       int prefixes;
       trie_node* child[26];

}*root=NULL;

// typedef so that the name becomes short
typedef struct trie_node tn;

//initialize the trie
void initializeRoot(tn *root)             
{
    tn* node=new tn;
    root=node;

    //initializing the trie root node
    for(int i=0;i < 26;i++)
             root-> child[i]=NULL;

    root-> words=0;
    root-> prefixes=0;
}

//add a child at character 'c' to a node 'node'
void addNode(tn *node, char c)          
{
     tn* childNode =new tn;

     for(int i=0;i < 26;i++)
             childNode->child[i]=NULL;

     childNode->words=0;
     childNode->prefixes=0;

     int index=(int)c-97;
     node->child[index]=childNode;
}

int findWord(tn *root, char *word)
{
     tn* curr;
     curr=root;
     int len=strlen(word);

     //find length of the word
     int i;
     for(i=0;i < len;i++)
     {
         // find the child of the current node depending on the next character
         int index = (int)word[i] - 97;         
         curr=curr->child[index];

          // if node exists then the word might exist
         if(curr==NULL)                        
           return NOT_FOUND;
     }
     if(i==len)
        return FOUND;
     else
         return NOT_FOUND;
}

void addWord(tn *root, char *word)
{
     int len=strlen(word);
     tn* curr=root;
     tn* parent=root;
     int i;
     for(i=0;i < len;i++)
     {
         // increment the number of prefix with the word till word[i]
         curr->prefixes++;

         int index= (int)word[i] - 97;            
         parent=curr;              
         curr=curr->child[i];

         // no child exists for word[i] -- create one
         if(curr==NULL)
            addNode(parent,word[i]);

         // word is finished increment the number of words
         if(i==len-1)
            curr->words++;              
     }
}

int countPrefix(tn *root, char *prefix)
{
     tn* curr;
     curr=root;
     int len=strlen(prefix);            
     int i;
     for(i=0;i < len;i++)
     {
         // find the child of the current node depending on the next character
         int index = (int)prefix[i] - 97;         
         curr=curr->child[index];

         // if node exists then the word might exist
         if(curr==NULL)                         
           return NOT_FOUND;
     }
     if(i==len)
        return curr->prefixes;
     else
         return NOT_FOUND;
}

int main()
{
    initializeRoot(root);
    system("pause");
    return 0;
}

Monday, August 20, 2012

Quick Sort


#include <iostream>

using namespace std;
int partition(int *a,int p,int r)
{
    int x=a[r];
    int temp;
    int i=p-1;
    int j=p;
    for(j=p;j<(r);j++)
    {
        if(a[j]<x)
        {
            i++;
            temp=a[j];
            a[j]=a[i];
            a[i]=temp;
        }


    }
    temp=a[r];
    a[r]=a[i+1];
    a[i+1]=temp;
    int k=0;
    return i+1;
}
void quickSort(int *a,int p,int r)
{


    int q;
    if(p<r)
    {

    q=partition (a,p,r);
    quickSort(a,p,q-1);
    quickSort(a,q+1,r);

    }

}
int main()
{
    int a[10];
    int i=0;
    while(i<10)
    cin>>a[i++];
    quickSort(a,0,9);
    i=0;
    while(i<10)
    cout<<a[i++]<<" ";



    return 0;
}