SMSing from computer

By Mourya
In general, there are two ways to send SMS messages from a computer / PC to a mobile phone:

Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the computer / PC and AT commands to instruct the mobile phone or GSM/GPRS modem to send SMS messages.

Connect the computer / PC to the SMS center (SMSC) or SMS gateway of a wireless carrier or SMS service provider. Then send SMS messages using a protocol / interface supported by the SMSC or SMS gateway.

If you do not want to develop SMS software or applications but just want to use your computer / PC to send text messages, you may want to read our Quick Guide for Non-Developers.


10.1. The 1st Way: Sending SMS Messages from a Computer Using a Mobile Phone or GSM/GPRS Modem

The SMS specification has defined a way for a computer to send SMS messages through a mobile phone or GSM/GPRS modem. A GSM/GPRS modem is a wireless modem that works with GSM/GPRS wireless networks. A wireless modem is similar to a dial-up modem. The main difference is that a wireless modem transmits data through a wireless network whereas a dial-up modem transmits data through a copper telephone line. More information about GSM/GPRS modems will be provided in the section "Introduction to GSM / GPRS Wireless Modems". Most mobile phones can be used as a wireless modem. However, some mobile phones have certain limitations comparing to GSM/GPRS modems. This will be discussed in the section "Which is Better: Mobile Phone or GSM / GPRS Modem" later.

To send SMS messages, first place a valid SIM card from a wireless carrier into a mobile phone or GSM/GPRS modem, which is then connected to a computer. There are several ways to connect a mobile phone or GSM/GPRS modem to a computer. For example, they can be connected through a serial cable, a USB cable, a Bluetooth link or an infrared link. The actual way to use depends on the capability of the mobile phone or GSM/GPRS modem. For example, if a mobile phone does not support Bluetooth, it cannot connect to the computer through a Bluetooth link.

After connecting a mobile phone or GSM/GPRS modem to a computer, you can control the mobile phone or GSM/GPRS modem by sending instructions to it. The instructions used for controlling the mobile phone or GSM/GPRS modem are called AT commands. (AT commands are also used to control dial-up modems for wired telephone system.) Dial-up modems, mobile phones and GSM/GPRS modems support a common set of standard AT commands. In addition to this common set of standard AT commands, mobile phones and GSM/GPRS modems support an extended set of AT commands. One use of the extended AT commands is to control the sending and receiving of SMS messages.

The following table lists the AT commands that are related to the writing and sending of SMS messages:


AT command

Meaning

+CMGS

Send message

+CMSS

Send message from storage

+CMGW

Write message to memory

+CMGD

Delete message

+CMGC

Send command

+CMMS

More messages to send


One way to send AT commands to a mobile phone or GSM/GPRS modem is to use a terminal program. A terminal program's function is like this: It sends the characters you typed to the mobile phone or GSM/GPRS modem. It then displays the response it receives from the mobile phone or GSM/GPRS modem on the screen. The terminal program on Microsoft Windows is called HyperTerminal. More details about the use of Microsoft HyperTerminal can be found in the "How to Use Microsoft HyperTerminal to Send AT Commands to a Mobile Phone or GSM/GPRS Modem" section of this SMS tutorial.

Below shows a simple example that demonstrates how to use AT commands and the HyperTerminal program of Microsoft Windows to send an SMS text message. The lines in bold type are the command lines that should be entered in HyperTerminal. The other lines are responses returned from the GSM / GPRS modem or mobile phone.


AT
OK
AT+CMGF=1
OK
AT+CMGW="+85291234567"
> A simple demo of SMS text messaging.
+CMGW: 1

OK
AT+CMSS=1
+CMSS: 20

OK


Here is a description of what is done in the above example:

Line 1: "AT" is sent to the GSM / GPRS modem to test the connection. The GSM / GPRS modem sends back the result code "OK" (line 2), which means the connection between the HyperTerminal program and the GSM / GPRS modem works fine.

Line 3: The AT command +CMGF is used to instruct the GSM / GPRS modem to operate in SMS text mode. The result code "OK" is returned (line 4), which indicates the command line "AT+CMGF=1" has been executed successfully. If the result code "ERROR" is returned, it is likely that the GSM / GPRS modem does not support the SMS text mode. To confirm, type "AT+CMGF=?" in the HyperTerminal program. If the response is "+CMGF: (0,1)" (0=PDU mode and 1=text mode), then SMS text mode is supported. If the response is "+CMGF: (0)", then SMS text mode is not supported.

Line 5 and 6: The AT command +CMGW is used to write an SMS text message to the message storage of the GSM / GPRS modem. "+85291234567" is the recipient mobile phone number. After typing the recipient mobile phone number, you should press the Enter button of the keyboard. The GSM / GPRS modem will then return a prompt "> " and you can start typing the SMS text message "A simple demo of SMS text messaging.". When finished, press Ctrl+z of the keyboard.

Line 7: "+CMGW: 1" tells us that the index assigned to the SMS text message is 1. It indicates the location of the SMS text message in the message storage.

Line 9: The result code "OK" indicates the execution of the AT command +CMGW is successful.

Line 10: The AT command +CMSS is used to send the SMS text message from the message storage of the GSM / GPRS modem. "1" is the index of the SMS text message obtained from line 7.

Line 11: "+CMSS: 20" tells us that the reference number assigned to the SMS text message is 20.

Line 13: The result code "OK" indicates the execution of the AT command +CMSS is successful.

To send SMS messages from an application, you have to write the source code for connecting to and sending AT commands to the mobile phone or GSM/GPRS modem, just like what a terminal program does. You can write the source code in C, C++, Java, Visual Basic, Delphi or other programming languages you like. However, writing your own code has a few disadvantages:

You have to learn how to use AT commands.

You have to learn how to compose the bits and bytes of an SMS message. For example, to specify the character encoding (e.g. 7-bit encoding and 16-bit Unicode encoding) of an SMS message, you need to know which bits in the message header should be modified and what value should be assigned.

Sending SMS messages with a mobile phone or GSM/GPRS modem has a drawback -- the SMS transmission speed is low. As your SMS messaging application becomes more popular, it has to handle a larger amount of SMS traffic and finally the mobile phone or GSM/GPRS modem will not be able to take the load. To obtain a high SMS transmission speed, a direct connection to an SMSC or SMS gateway of a wireless carrier or SMS service provider is needed. However, AT commands are not used for communicating with an SMS center or SMS gateway. This means your have to make a big change to your SMS messaging application in order to move from a wireless-modem-based solution to a SMSC-based solution.

In most cases, instead of writing your own code for interacting with the mobile phone or GSM/GPRS modem via AT commands, a better solution is to use a high-level SMS messaging API (Application programming interface) / SDK (Software development kit) / library. The API / SDK / library encapsulates the low-level details. So, an SMS application developer does not need to know AT commands and the composition of SMS messages in the bit-level. Some SMS messaging APIs / SDKs / libraries support SMSC protocols in addition to AT commands. To move from a wireless-modem-based SMS solution to a SMSC-based SMS solution, usually you just need to modify a configuration file / property file or make a few changes to your SMS messaging application's source code.

The links to some open source and free SMS messaging libraries can be found in the article "Free Libraries/Tools for Sending/Receiving SMS with a Computer".

Another way to hide the low-level AT command layer is to place an SMS gateway between the SMS messaging application and the mobile phone or GSM/GPRS modem. (This has been described in the section "What is an SMS Gateway?" earlier.) Simple protocols such as HTTP / HTTPS can then be used for sending SMS messages in the application. If an SMSC protocol (e.g. SMPP, CIMD, etc) is used for communicating with the SMS gateway instead of HTTP / HTTPS, an SMS messaging API / SDK / library can be very helpful to you since it encapsulates the SMSC protocol's details.

Usually a list of supported / unsupported mobile phones or wireless modems is provided on the web site of an SMS messaging API / SDK / library or an SMS gateway software package. Remember to check the list if you are going to use an SMS messaging API / SDK / library or an SMS gateway software package.


10.1.1. Major Drawback of Sending SMS Messages through a Mobile Phone or GSM/GPRS Modem -- Low SMS Sending Rate

Using a mobile phone or GSM/GPRS modem to send SMS messages has a major drawback, that is the SMS sending rate is too low. Only 6-10 SMS messages can be sent per minute (when the "SMS over GSM" mode is used). The performance is not affected by the connection between the computer and the mobile phone or GSM/GPRS modem (i.e. the SMS sending rate is about the same no matter the mobile phone or GSM/GPRS modem is connected to the computer through a serial cable, USB cable, Bluetooth link or infrared link) and does not depend on whether a mobile phone or GSM/GPRS modem is used (i.e. the SMS sending rate is about the same no matter a mobile phone or a GSM/GPRS modem is used). The determining factor for the SMS sending rate is the wireless network.

In general, there are two ways to send SMS messages from a computer / PC to a mobile phone:

Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the computer / PC and AT commands to instruct the mobile phone or GSM/GPRS modem to send SMS messages.

Connect the computer / PC to the SMS center (SMSC) or SMS gateway of a wireless carrier or SMS service provider. Then send SMS messages using a protocol / interface supported by the SMSC or SMS gateway.

If you do not want to develop SMS software or applications but just want to use your computer / PC to send text messages, you may want to read our Quick Guide for Non-Developers.


10.1. The 1st Way: Sending SMS Messages from a Computer Using a Mobile Phone or GSM/GPRS Modem

The SMS specification has defined a way for a computer to send SMS messages through a mobile phone or GSM/GPRS modem. A GSM/GPRS modem is a wireless modem that works with GSM/GPRS wireless networks. A wireless modem is similar to a dial-up modem. The main difference is that a wireless modem transmits data through a wireless network whereas a dial-up modem transmits data through a copper telephone line. More information about GSM/GPRS modems will be provided in the section "Introduction to GSM / GPRS Wireless Modems". Most mobile phones can be used as a wireless modem. However, some mobile phones have certain limitations comparing to GSM/GPRS modems. This will be discussed in the section "Which is Better: Mobile Phone or GSM / GPRS Modem" later.

To send SMS messages, first place a valid SIM card from a wireless carrier into a mobile phone or GSM/GPRS modem, which is then connected to a computer. There are several ways to connect a mobile phone or GSM/GPRS modem to a computer. For example, they can be connected through a serial cable, a USB cable, a Bluetooth link or an infrared link. The actual way to use depends on the capability of the mobile phone or GSM/GPRS modem. For example, if a mobile phone does not support Bluetooth, it cannot connect to the computer through a Bluetooth link.

After connecting a mobile phone or GSM/GPRS modem to a computer, you can control the mobile phone or GSM/GPRS modem by sending instructions to it. The instructions used for controlling the mobile phone or GSM/GPRS modem are called AT commands. (AT commands are also used to control dial-up modems for wired telephone system.) Dial-up modems, mobile phones and GSM/GPRS modems support a common set of standard AT commands. In addition to this common set of standard AT commands, mobile phones and GSM/GPRS modems support an extended set of AT commands. One use of the extended AT commands is to control the sending and receiving of SMS messages.

The following table lists the AT commands that are related to the writing and sending of SMS messages:


AT command

Meaning

+CMGS

Send message

+CMSS

Send message from storage

+CMGW

Write message to memory

+CMGD

Delete message

+CMGC

Send command

+CMMS

More messages to send


One way to send AT commands to a mobile phone or GSM/GPRS modem is to use a terminal program. A terminal program's function is like this: It sends the characters you typed to the mobile phone or GSM/GPRS modem. It then displays the response it receives from the mobile phone or GSM/GPRS modem on the screen. The terminal program on Microsoft Windows is called HyperTerminal. More details about the use of Microsoft HyperTerminal can be found in the "How to Use Microsoft HyperTerminal to Send AT Commands to a Mobile Phone or GSM/GPRS Modem" section of this SMS tutorial.

Below shows a simple example that demonstrates how to use AT commands and the HyperTerminal program of Microsoft Windows to send an SMS text message. The lines in bold type are the command lines that should be entered in HyperTerminal. The other lines are responses returned from the GSM / GPRS modem or mobile phone.


AT
OK
AT+CMGF=1
OK
AT+CMGW="+85291234567"
> A simple demo of SMS text messaging.
+CMGW: 1

OK
AT+CMSS=1
+CMSS: 20

OK


Here is a description of what is done in the above example:

Line 1: "AT" is sent to the GSM / GPRS modem to test the connection. The GSM / GPRS modem sends back the result code "OK" (line 2), which means the connection between the HyperTerminal program and the GSM / GPRS modem works fine.

Line 3: The AT command +CMGF is used to instruct the GSM / GPRS modem to operate in SMS text mode. The result code "OK" is returned (line 4), which indicates the command line "AT+CMGF=1" has been executed successfully. If the result code "ERROR" is returned, it is likely that the GSM / GPRS modem does not support the SMS text mode. To confirm, type "AT+CMGF=?" in the HyperTerminal program. If the response is "+CMGF: (0,1)" (0=PDU mode and 1=text mode), then SMS text mode is supported. If the response is "+CMGF: (0)", then SMS text mode is not supported.

Line 5 and 6: The AT command +CMGW is used to write an SMS text message to the message storage of the GSM / GPRS modem. "+85291234567" is the recipient mobile phone number. After typing the recipient mobile phone number, you should press the Enter button of the keyboard. The GSM / GPRS modem will then return a prompt "> " and you can start typing the SMS text message "A simple demo of SMS text messaging.". When finished, press Ctrl+z of the keyboard.

Line 7: "+CMGW: 1" tells us that the index assigned to the SMS text message is 1. It indicates the location of the SMS text message in the message storage.

Line 9: The result code "OK" indicates the execution of the AT command +CMGW is successful.

Line 10: The AT command +CMSS is used to send the SMS text message from the message storage of the GSM / GPRS modem. "1" is the index of the SMS text message obtained from line 7.

Line 11: "+CMSS: 20" tells us that the reference number assigned to the SMS text message is 20.

Line 13: The result code "OK" indicates the execution of the AT command +CMSS is successful.

To send SMS messages from an application, you have to write the source code for connecting to and sending AT commands to the mobile phone or GSM/GPRS modem, just like what a terminal program does. You can write the source code in C, C++, Java, Visual Basic, Delphi or other programming languages you like. However, writing your own code has a few disadvantages:

You have to learn how to use AT commands.

You have to learn how to compose the bits and bytes of an SMS message. For example, to specify the character encoding (e.g. 7-bit encoding and 16-bit Unicode encoding) of an SMS message, you need to know which bits in the message header should be modified and what value should be assigned.

Sending SMS messages with a mobile phone or GSM/GPRS modem has a drawback -- the SMS transmission speed is low. As your SMS messaging application becomes more popular, it has to handle a larger amount of SMS traffic and finally the mobile phone or GSM/GPRS modem will not be able to take the load. To obtain a high SMS transmission speed, a direct connection to an SMSC or SMS gateway of a wireless carrier or SMS service provider is needed. However, AT commands are not used for communicating with an SMS center or SMS gateway. This means your have to make a big change to your SMS messaging application in order to move from a wireless-modem-based solution to a SMSC-based solution.

In most cases, instead of writing your own code for interacting with the mobile phone or GSM/GPRS modem via AT commands, a better solution is to use a high-level SMS messaging API (Application programming interface) / SDK (Software development kit) / library. The API / SDK / library encapsulates the low-level details. So, an SMS application developer does not need to know AT commands and the composition of SMS messages in the bit-level. Some SMS messaging APIs / SDKs / libraries support SMSC protocols in addition to AT commands. To move from a wireless-modem-based SMS solution to a SMSC-based SMS solution, usually you just need to modify a configuration file / property file or make a few changes to your SMS messaging application's source code.

The links to some open source and free SMS messaging libraries can be found in the article "Free Libraries/Tools for Sending/Receiving SMS with a Computer".

Another way to hide the low-level AT command layer is to place an SMS gateway between the SMS messaging application and the mobile phone or GSM/GPRS modem. (This has been described in the section "What is an SMS Gateway?" earlier.) Simple protocols such as HTTP / HTTPS can then be used for sending SMS messages in the application. If an SMSC protocol (e.g. SMPP, CIMD, etc) is used for communicating with the SMS gateway instead of HTTP / HTTPS, an SMS messaging API / SDK / library can be very helpful to you since it encapsulates the SMSC protocol's details.

Usually a list of supported / unsupported mobile phones or wireless modems is provided on the web site of an SMS messaging API / SDK / library or an SMS gateway software package. Remember to check the list if you are going to use an SMS messaging API / SDK / library or an SMS gateway software package.


10.1.1. Major Drawback of Sending SMS Messages through a Mobile Phone or GSM/GPRS Modem -- Low SMS Sending Rate

Using a mobile phone or GSM/GPRS modem to send SMS messages has a major drawback, that is the SMS sending rate is too low. Only 6-10 SMS messages can be sent per minute (when the "SMS over GSM" mode is used). The performance is not affected by the connection between the computer and the mobile phone or GSM/GPRS modem (i.e. the SMS sending rate is about the same no matter the mobile phone or GSM/GPRS modem is connected to the computer through a serial cable, USB cable, Bluetooth link or infrared link) and does not depend on whether a mobile phone or GSM/GPRS modem is used (i.e. the SMS sending rate is about the same no matter a mobile phone or a GSM/GPRS modem is used). The determining factor for the SMS sending rate is the wireless network.

 

NEED FOR SPEED- UNDERCOVER....

By Shashank Krishna
 

Is IIS worth the effort for hosting

Category: , , By Mourya
First of all i have to apologize to the readers because i couldn't post for a long duration (thanks to my health,and the net,and the college portal).Today we finally hosted the web portal in the intranet and if you happen to belong to my department the portal address is http://192.168.12.4:5120 however we would be shortly creating a domain for the convenience and upload it to the net.So in the morning we first thought of using tomcat web server for hosting the portal.However i ended up hosting using IIS.The problem i faced with Tomcat was that after installing the version 5.I tried the localhost and couldnt access the netadmin.Heard that a connector should be supplied for that.Though i changed the users in the users.xml file,it wasn't of much help.

Though i never used IIS ,i felt it was the same old windows next,next clicking type.You hardly need any knowledge for that except basic networking.Did a bit of googling and completed the configuration.Will write a tutorial on the hosting as well as setting a virtual machine very shortly.Till then good bye

First of all i have to apologize to the readers because i couldn't post for a long duration (thanks to my health,and the net,and the college portal).Today we finally hosted the web portal in the intranet and if you happen to belong to my department the portal address is http://192.168.12.4:5120 however we would be shortly creating a domain for the convenience and upload it to the net.So in the morning we first thought of using tomcat web server for hosting the portal.However i ended up hosting using IIS.The problem i faced with Tomcat was that after installing the version 5.I tried the localhost and couldnt access the netadmin.Heard that a connector should be supplied for that.Though i changed the users in the users.xml file,it wasn't of much help.

Though i never used IIS ,i felt it was the same old windows next,next clicking type.You hardly need any knowledge for that except basic networking.Did a bit of googling and completed the configuration.Will write a tutorial on the hosting as well as setting a virtual machine very shortly.Till then good bye

 

So is the wait for an online Web Builder finally come to an end?

Category: , By Mourya
Thanks to all the readers for criticizing me on my last article (The evil Empire).Today while going over the initial layout, i wondered whether the so called online web site builders do any justice.I went across few sites and made few comments.Though these sites are quite helpful for customers without much exposure to the web world, these might be quite irritating for choosy customers.Those who are well aware about their business want web sites specially tailored to entertain the needs of their customers.So when these sites come up with the usual stuff in different looks,they are left unsatisfied.

I remembered a friend of mine doing his post graduation in IISc speaking about a online web builder which can satisfy the customer to the finest.So i thought about it for quite some time.Few conclusions i made were a virtual dashboard of the layout and both the designer as well as the customer can edit them as well as put content.Though Java can be used to develop such an application it would be quite gruesome for the customers to understand the interface.One more interesting developer is the new FLEX BUILDER which has the potential to develop an online OS.So i wouldn't be surprised if such a Builder comes up in a day or two.

Thanks to all the readers for criticizing me on my last article (The evil Empire).Today while going over the initial layout, i wondered whether the so called online web site builders do any justice.I went across few sites and made few comments.Though these sites are quite helpful for customers without much exposure to the web world, these might be quite irritating for choosy customers.Those who are well aware about their business want web sites specially tailored to entertain the needs of their customers.So when these sites come up with the usual stuff in different looks,they are left unsatisfied.

I remembered a friend of mine doing his post graduation in IISc speaking about a online web builder which can satisfy the customer to the finest.So i thought about it for quite some time.Few conclusions i made were a virtual dashboard of the layout and both the designer as well as the customer can edit them as well as put content.Though Java can be used to develop such an application it would be quite gruesome for the customers to understand the interface.One more interesting developer is the new FLEX BUILDER which has the potential to develop an online OS.So i wouldn't be surprised if such a Builder comes up in a day or two.

 

The New Evil Empire?

Category: , By Mourya
As google would be celebrating it's tenth anniversary this month,we can recall the events of the past 10 years.Google when contrasted with Microsoft either in monetary terms or hostility terms the latter is gaining more popularity.This is a good sign for the cool startup a decade ago.

But there are few things that disturb my mind a lot.Google is everywhere these days especially after entering the Microsoft domain with its's new browser Chrome,this are hot'ing up between these two.But can we escape from Google eyes( or the cookies).

The google has grown up from keyword search to a altamater for the net users.The keyword search developed into page search.Now it has created an ultimate alternative for TV with it's acquisition of You Tube.Guess it is trying to develop an alternative for every service on the net in it's own style.Whether it's our favorite orkut,or the new knools(wikis).

How ever the security regarding our privacy is getting lost.Because of its Adsense it tracks our IP Address and keep track of all our activities through its cookies and IP tracking.

While others say privacy concerns about the wat it operates,Google wants to be seen youthful,friendly and benign.Wondering why i am in a way critizing my own dream company,it's a part of the liking.Finally concluding putting on question."Doesn't get Evil",does it hold good?

As google would be celebrating it's tenth anniversary this month,we can recall the events of the past 10 years.Google when contrasted with Microsoft either in monetary terms or hostility terms the latter is gaining more popularity.This is a good sign for the cool startup a decade ago.

But there are few things that disturb my mind a lot.Google is everywhere these days especially after entering the Microsoft domain with its's new browser Chrome,this are hot'ing up between these two.But can we escape from Google eyes( or the cookies).

The google has grown up from keyword search to a altamater for the net users.The keyword search developed into page search.Now it has created an ultimate alternative for TV with it's acquisition of You Tube.Guess it is trying to develop an alternative for every service on the net in it's own style.Whether it's our favorite orkut,or the new knools(wikis).

How ever the security regarding our privacy is getting lost.Because of its Adsense it tracks our IP Address and keep track of all our activities through its cookies and IP tracking.

While others say privacy concerns about the wat it operates,Google wants to be seen youthful,friendly and benign.Wondering why i am in a way critizing my own dream company,it's a part of the liking.Finally concluding putting on question."Doesn't get Evil",does it hold good?

 

Weekend tech

Category: By Mourya
So done with most of the internals.Today after a tiring game of basketball,i retired peacefully into dreams(bus wala...).After coming home, i had a party to attend, so got dressed up(a chic kill)and went to friends room.Watched around an hour movie on his lappy.I found sumthing strange.The HP series of the desktop and laptop with same configuration,the laptop works better with vista than the desktop.


Niway leaving apart the techno stuff for sometime,we went to a restaurant.We know how gruesum it would be to wait at restaurants,but there is no alternative.Hey wait,there is an alternative.How would be the life if we can book the dishes and places from our favourite restaurant with only few clicks.A very Stupid Idea right.

Though it was a stupid idea,it would work because most of us are lazy to even switch our pc's off leave alone standing in theaters.Those days are gone,thanks to AARVY MOVIES.So i guess a portal where the information about Different Dishes at Different Restaurants sound...Pretty Gr8 rite?

Will be informing more about it soon.It's time to hit bed(that's what my Mom thinks so).Time for a short break.

So done with most of the internals.Today after a tiring game of basketball,i retired peacefully into dreams(bus wala...).After coming home, i had a party to attend, so got dressed up(a chic kill)and went to friends room.Watched around an hour movie on his lappy.I found sumthing strange.The HP series of the desktop and laptop with same configuration,the laptop works better with vista than the desktop.


Niway leaving apart the techno stuff for sometime,we went to a restaurant.We know how gruesum it would be to wait at restaurants,but there is no alternative.Hey wait,there is an alternative.How would be the life if we can book the dishes and places from our favourite restaurant with only few clicks.A very Stupid Idea right.

Though it was a stupid idea,it would work because most of us are lazy to even switch our pc's off leave alone standing in theaters.Those days are gone,thanks to AARVY MOVIES.So i guess a portal where the information about Different Dishes at Different Restaurants sound...Pretty Gr8 rite?

Will be informing more about it soon.It's time to hit bed(that's what my Mom thinks so).Time for a short break.

 

Reverese Engineering the Extra Terrestrial

Category: By Mourya


After the successful testing of the LHC at CERN, i was left wondering whether spending so much money on fulfilling the thirst of Curiosity is necessary.From the days since i first saw E.T ( Extra Terrestrial ) i was touched with curiosity of proof.So to the reference of my above idea of curiosity i would like to relate myself to the latter idea.


Niway let me start from my first thoughts,I do believe in the existence of life else where because of the probabity of existence.So after watching lot of Movies especially The famous Independence Day and the Close Encounters of the third kind,i came across few articles on Area 51 and the conspiracies involving Unites States of America.So after a long googling on these articles the curiosity in me grew to much higher levels.So checked with the Google Maps but had no much luck.

Finally i found a guy from my place who used to work in AREA 51 on Reverse Engineering.I believed a lot on this guy and tried to get as much information as possible.However later i found out that this guy is a fraud.

After such bad encounters i restarted working on a model or infact a prototype using a flying saucer model on Anti Gravity Levetation.Though i did it using some 3d objects and thanks to the mechanical and electrical students for thier ideas on the principals i finally completed the project much to the dismay the result was negative.


When asked about on what principals does this prototype work, i would say actually i had the idea of repel nature of particles and magnets.One interesting fact about gravitational or magnetic property is that they dont use energy to repel like poles.
If We can consider Earth as a big magnet and create a model of the same pole as that of the earth then we can repel the model from the earth.Wondering for people to put their comments.




After the successful testing of the LHC at CERN, i was left wondering whether spending so much money on fulfilling the thirst of Curiosity is necessary.From the days since i first saw E.T ( Extra Terrestrial ) i was touched with curiosity of proof.So to the reference of my above idea of curiosity i would like to relate myself to the latter idea.


Niway let me start from my first thoughts,I do believe in the existence of life else where because of the probabity of existence.So after watching lot of Movies especially The famous Independence Day and the Close Encounters of the third kind,i came across few articles on Area 51 and the conspiracies involving Unites States of America.So after a long googling on these articles the curiosity in me grew to much higher levels.So checked with the Google Maps but had no much luck.

Finally i found a guy from my place who used to work in AREA 51 on Reverse Engineering.I believed a lot on this guy and tried to get as much information as possible.However later i found out that this guy is a fraud.

After such bad encounters i restarted working on a model or infact a prototype using a flying saucer model on Anti Gravity Levetation.Though i did it using some 3d objects and thanks to the mechanical and electrical students for thier ideas on the principals i finally completed the project much to the dismay the result was negative.


When asked about on what principals does this prototype work, i would say actually i had the idea of repel nature of particles and magnets.One interesting fact about gravitational or magnetic property is that they dont use energy to repel like poles.
If We can consider Earth as a big magnet and create a model of the same pole as that of the earth then we can repel the model from the earth.Wondering for people to put their comments.



 

Big Bang !!once again

Category: By Mourya
After the hype from the media regarding the much awaited Large Hadron Collider(LHC) at CERN tommorow, i recalled few incidence and few frictional facts i read long time back.For those living in stone age or haven't seen a newspaper since olympics closing cermony here is a quick refernce.

CERN is an european organization for nuclear research.But what's it to do.However one more important function for CERN is to provide partical accelerators and other infra structure needed for high-energy physics research.

So coming to recent news,a much awaited $5.6billion project consisting of 17 miles tunnel dug under 27 km from the surface ,revloving around the border of France and Swiss particle accelerator is yet to make history by coming into life on wednesday morning 1200 EDT.

This particle accelerator actually accelerators a pair of protons in the opposite direction till they almost attain the speed of light and then collide.The Immediate reaction after the head-on collision will be a great study for solving some of the mysteries regarding the universe and existence.

I remember reading Dan Brown's Angels and Demons in which they exists a spoon of anti matter created when two z-particles(guess it is fiction) collide head on in CERN resulting in the creation of matter and anti matter from the surrounding energy.If this really happens then careful security measures should be taken because i remember reading if matter and anti matter annihilate they produce a large amount of energy.

Today in the evening while watching a news programme on this LHC there are few views from eminent scientists saying that there is a possibility of creation of a black hole which can lead to the collapse of the Earth.Though these news channels are hyping too much to increase their view brand ,I believe it doesn't actually make sense.Cause i read that the possible amount of energy that can be produces is around 20 Tera Electron Volts.Those this is a large amount of energy,it might not be possible to destroy the world.And coming to creating a black hole, I'm illiterate in the scientifical explanation yet.Would be posting a review tomorrow after the initial results are out.

Hoping we are alive till then
signing off.

After the hype from the media regarding the much awaited Large Hadron Collider(LHC) at CERN tommorow, i recalled few incidence and few frictional facts i read long time back.For those living in stone age or haven't seen a newspaper since olympics closing cermony here is a quick refernce.

CERN is an european organization for nuclear research.But what's it to do.However one more important function for CERN is to provide partical accelerators and other infra structure needed for high-energy physics research.

So coming to recent news,a much awaited $5.6billion project consisting of 17 miles tunnel dug under 27 km from the surface ,revloving around the border of France and Swiss particle accelerator is yet to make history by coming into life on wednesday morning 1200 EDT.

This particle accelerator actually accelerators a pair of protons in the opposite direction till they almost attain the speed of light and then collide.The Immediate reaction after the head-on collision will be a great study for solving some of the mysteries regarding the universe and existence.

I remember reading Dan Brown's Angels and Demons in which they exists a spoon of anti matter created when two z-particles(guess it is fiction) collide head on in CERN resulting in the creation of matter and anti matter from the surrounding energy.If this really happens then careful security measures should be taken because i remember reading if matter and anti matter annihilate they produce a large amount of energy.

Today in the evening while watching a news programme on this LHC there are few views from eminent scientists saying that there is a possibility of creation of a black hole which can lead to the collapse of the Earth.Though these news channels are hyping too much to increase their view brand ,I believe it doesn't actually make sense.Cause i read that the possible amount of energy that can be produces is around 20 Tera Electron Volts.Those this is a large amount of energy,it might not be possible to destroy the world.And coming to creating a black hole, I'm illiterate in the scientifical explanation yet.Would be posting a review tomorrow after the initial results are out.

Hoping we are alive till then
signing off.

 

Algorithms made easy

Category: By Mourya
Introduction
The first step towards an understanding of why the study and knowledge of algorithms are so important is to define exactly what we mean by an algorithm. According to the popular algorithms textbook Introduction to Algorithms (Second Edition by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein), "an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values as output." In other words, algorithms are like road maps for accomplishing a given, well-defined task. So, a chunk of code that calculates the terms of the Fibonacci sequence is an implementation of a particular algorithm. Even a simple function for adding two numbers is an algorithm in a sense, albeit a simple one.

Some algorithms, like those that compute the Fibonacci sequences, are intuitive and may be innately embedded into our logical thinking and problem solving skills. However, for most of us, complex algorithms are best studied so we can use them as building blocks for more efficient logical problem solving in the future. In fact, you may be surprised to learn just how many complex algorithms people use every day when they check their e-mail or listen to music on their computers. This article will introduce some basic ideas related to the analysis of algorithms, and then put these into practice with a few examples illustrating why it is important to know about algorithms.

Runtime Analysis
One of the most important aspects of an algorithm is how fast it is. It is often easy to come up with an algorithm to solve a problem, but if the algorithm is too slow, it's back to the drawing board. Since the exact speed of an algorithm depends on where the algorithm is run, as well as the exact details of its implementation, computer scientists typically talk about the runtime relative to the size of the input. For example, if the input consists of N integers, an algorithm might have a runtime proportional to N2, represented as O(N2). This means that if you were to run an implementation of the algorithm on your computer with an input of size N, it would take C*N2 seconds, where C is some constant that doesn't change with the size of the input.

However, the execution time of many complex algorithms can vary due to factors other than the size of the input. For example, a sorting algorithm may run much faster when given a set of integers that are already sorted than it would when given the same set of integers in a random order. As a result, you often hear people talk about the worst-case runtime, or the average-case runtime. The worst-case runtime is how long it would take for the algorithm to run if it were given the most insidious of all possible inputs. The average-case runtime is the average of how long it would take the algorithm to run if it were given all possible inputs. Of the two, the worst-case is often easier to reason about, and therefore is more frequently used as a benchmark for a given algorithm. The process of determining the worst-case and average-case runtimes for a given algorithm can be tricky, since it is usually impossible to run an algorithm on all possible inputs. There are many good online resources that can help you in estimating these values.

Approximate completion time for algorithms, N = 100
O(Log(N)) 10-7 seconds
O(N) 10-6 seconds
O(N*Log(N)) 10-5 seconds
O(N2) 10-4 seconds
O(N6) 3 minutes
O(2N) 1014 years.
O(N!) 10142 years.

Sorting
Sorting provides a good example of an algorithm that is very frequently used by computer scientists. The simplest way to sort a group of items is to start by removing the smallest item from the group, and put it first. Then remove the next smallest, and put it next and so on. Unfortunately, this algorithm is O(N2), meaning that the amount of time it takes is proportional to the number of items squared. If you had to sort a billion things, this algorithm would take around 1018 operations. To put this in perspective, a desktop PC can do a little bit over 109 operations per second, and would take years to finish sorting a billion things this way.

Luckily, there are a number of better algorithms (quicksort, heapsort and mergesort, for example) that have been devised over the years, many of which have a runtime of O(N * Log(N)). This brings the number of operations required to sort a billion items down to a reasonable number that even a cheap desktop could perform. Instead of a billion squared operations (1018) these algorithms require only about 10 billion operations (1010), a factor of 100 million faster.

Shortest Path
Algorithms for finding the shortest path from one point to another have been researched for years. Applications abound, but lets keep things simple by saying we want to find the shortest path from point A to point B in a city with just a few streets and intersections. There are quite a few different algorithms that have been developed to solve such problems, all with different benefits and drawbacks. Before we delve into them though, lets consider how long a naive algorithm - one that tries every conceivable option - would take to run. If the algorithm considered every possible path from A to B (that didn't go in circles), it would not finish in our lifetimes, even if A and B were both in a small town. The runtime of this algorithm is exponential in the size of the input, meaning that it is O(CN) for some C. Even for small values of C, CN becomes astronomical when N gets even moderately large.

One of the fastest algorithms for solving this problem has a runtime of O(E*V*Log(V)), where E is the number of road segments, and V is the number of intersections. To put this in perspective, the algorithm would take about 2 seconds to find the shortest path in a city with 10,000 intersections, and 20,000 road segments (there are usually about 2 road segments per intersection). The algorithm, known as Djikstra's Algorithm, is fairly complex, and requires the use of a data structure known as a priority queue. In some applications, however, even this runtime is too slow (consider finding the shortest path from New York City to San Francisco - there are millions of intersections in the US), and programmers try to do better by using what are known as heuristics. A heuristic is an approximation of something that is relevant to the problem, and is often computed by an algorithm of its own. In the shortest path problem, for example, it is useful to know approximately how far a point is from the destination. Knowing this allows for the development of faster algorithms (such as A*, an algorithm that can sometimes run significantly faster than Djikstra's algorithm) and so programmers come up with heuristics to approximate this value. Doing so does not always improve the runtime of the algorithm in the worst case, but it does make the algorithm faster in most real-world applications.

Approximate algorithms
Sometimes, however, even the most advanced algorithm, with the most advanced heuristics, on the fastest computers is too slow. In this case, sacrifices must be made that relate to the correctness of the result. Rather than trying to get the shortest path, a programmer might be satisfied to find a path that is at most 10% longer than the shortest path.

In fact, there are quite a few important problems for which the best-known algorithm that produces an optimal answer is insufficiently slow for most purposes. The most famous group of these problems is called NP, which stands for non-deterministic polynomial (don't worry about what that means). When a problem is said to be NP-complete or NP-hard, it mean no one knows a good way to solve them optimally. Furthermore, if someone did figure out an efficient algorithm for one NP-hard problem, that algorithm would be applicable to all NP-hard problems.

A good example of an NP-hard problem is the famous traveling salesman problem. A salesman wants to visit N cities, and he knows how long it takes to get from each city to each other city. The question is "how fast can he visit all of the cities?" Since the fastest known algorithm for solving this problem is too slow - and many believe this will always be true - programmers look for sufficiently fast algorithms that give good, but not optimal solutions.

Random Algorithms
Yet another approach to some problems is to randomize an algorithm is some way. While doing so does not improve the algorithm in the worst case, it often makes very good algorithms in the average case. Quicksort is a good example of an algorithm where randomization is often used. In the worst case, quicksort sorts a group of items in O(N2), where N is the number of items. If randomization is incorporated into the algorithm, however, the chances of the worst case actually occurring become diminishingly small, and on average, quicksort has a runtime of O(N*Log(N)). Other algorithms guarantee a runtime of O(N*Log(N)), even in the worst case, but they are slower in the average case. Even though both algorithms have a runtime proportional to N*Log(N), quicksort has a smaller constant factor - that is it requires C*N*Log(N) operations, while other algorithms require more like 2*C*N*Log(N) operations.

Another algorithm that uses random numbers finds the median of a group of numbers with an average runtime of O(N). This is a significant improvement over sorting the numbers and taking the middle one, which takes O(N*Log(N)). Furthermore, while deterministic (non-random) algorithms exist for finding the median with a runtime of O(N), the random algorithm is attractively simple, and often faster than the deterministic algorithms.

The basic idea of the median algorithm is to pick one of the numbers in the group at random, and count how many of the numbers in the group are less than it. Lets say there are N numbers, and K of them are less than or equal to the number we picked at random. If K is less than half of N, then we know that the median is the (N/2-K) th number that is greater than the random number we picked, so we discard the K numbers less than or equal to the random number. Now, we want to find the (N/2-K) th smallest number, instead of the median. The algorithm is the same though, and we simply pick another number at random, and repeat the above steps.

Compression
Another class of algorithm deals with situations such as data compression. This type of algorithm does not have an expected output (like a sorting algorithm), but instead tries to optimize some other criteria. In the case of data compression, the algorithm (LZW, for instance) tries to make the data use as few bytes as possible, in such a way that it can be decompressed to its original form. In some cases, this type of algorithm will use the same techniques as other algorithms, resulting in output that is good, but potentially sub-optimal. JPG and MP3 compression, for example, both compress data in a way that makes the final result somewhat lower quality than the original, but they create much smaller files. MP3 compression does not retain every feature of the original song file, but it attempts to maintain enough of the details to capture most of the quality, while at the same time ensuring the significantly reduced file size that we all know and love. The JPG image file format follows the same principle, but the details are significantly different since the goal is image rather than audio compression.

The Importance of Knowing Algorithms
As a computer scientist, it is important to understand all of these types of algorithms so that one can use them properly. If you are working on an important piece of software, you will likely need to be able to estimate how fast it is going to run. Such an estimate will be less accurate without an understanding of runtime analysis. Furthermore, you need to understand the details of the algorithms involved so that you'll be able to predict if there are special cases in which the software won't work quickly, or if it will produce unacceptable results.

Of course, there are often times when you'll run across a problem that has not been previously studied. In these cases, you have to come up with a new algorithm, or apply an old algorithm in a new way. The more you know about algorithms in this case, the better your chances are of finding a good way to solve the problem. In many cases, a new problem can be reduced to an old problem without too much effort, but you will need to have a fundamental understanding of the old problem in order to do this.

As an example of this, lets consider what a switch does on the Internet. A switch has N cables plugged into it, and receives packets of data coming in from the cables. The switch has to first analyze the packets, and then send them back out on the correct cables. A switch, like a computer, is run by a clock with discrete steps - the packets are send out at discrete intervals, rather than continuously. In a fast switch, we want to send out as many packets as possible during each interval so they don't stack up and get dropped. The goal of the algorithm we want to develop is to send out as many packets as possible during each interval, and also to send them out so that the ones that arrived earlier get sent out earlier. In this case it turns out that an algorithm for a problem that is known as "stable matching" is directly applicable to our problem, though at first glance this relationship seems unlikely. Only through pre-existing algorithmic knowledge and understanding can such a relationship be discovered.

More Real-world Examples
Other examples of real-world problems with solutions requiring advanced algorithms abound. Almost everything that you do with a computer relies in some way on an algorithm that someone has worked very hard to figure out. Even the simplest application on a modern computer would not be possible without algorithms being utilized behind the scenes to manage memory and load data from the hard drive.

There are dozens of applications of complicated algorithms, but I'm going to discuss two problems that require the same skills as some past TopCoder problems. The first is known as the maximum flow problem, and the second is related to dynamic programming, a technique that often solves seemingly impossible problems in blazing speed.

Maximum Flow
The maximum flow problem has to do with determining the best way to get some sort of stuff from one place to another, through a network of some sort. In more concrete terms, the problem first arose in relation to the rail networks of the Soviet Union, during the 1950's. The US wanted to know how quickly the Soviet Union could get supplies through its rail network to its satellite states in Eastern Europe.

In addition, the US wanted to know which rails it could destroy most easily to cut off the satellite states from the rest of the Soviet Union. It turned out that these two problems were closely related, and that solving the max flow problem also solves the min cut problem of figuring out the cheapest way to cut off the Soviet Union from its satellites.

The first efficient algorithm for finding the maximum flow was conceived by two Computer Scientists, named Ford and Fulkerson. The algorithm was subsequently named the Ford-Fulkerson algorithm, and is one of the more famous algorithms in computer science. In the last 50 years, a number of improvements have been made to the Ford-Fulkerson algorithm to make it faster, some of which are dauntingly complex.

Since the problem was first posed, many additional applications have been discovered. The algorithm has obvious relevance to the Internet, where getting as much data as possible from one point to another is important. It also comes up in many business settings, and is an important part of operations research. For example, if you have N employees and N jobs that need to be done, but not every employee can do every job, the max flow algorithm will tell you how to assign your N employees to jobs in such a way that every job gets done, provided that's possible. Graduation, from SRM 200, is a good example of a TopCoder problem that lends itself to a solution using max flow.

Sequence comparison
Many coders go their entire careers without ever having to implement an algorithm that uses dynamic programming. However, dynamic programming pops up in a number of important algorithms. One algorithm that most programmers have probably used, even though they may not have known it, finds differences between two sequences. More specifically, it calculates the minimum number of insertions, deletions, and edits required to transform sequence A into sequence B.

For example, lets consider two sequences of letters, "AABAA" and "AAAB". To transform the first sequence into the second, the simplest thing to do is delete the B in the middle, and change the final A into a B. This algorithm has many applications, including some DNA problems and plagiarism detection. However, the form in which many programmers use it is when comparing two versions of the same source code file. If the elements of the sequence are lines in the file, then this algorithm can tell a programmer which lines of code were removed, which ones were inserted, and which ones were modified to get from one version to the next.

Without dynamic programming, we would have to consider a - you guessed it - exponential number of transformations to get from one sequence to the other. As it is, however, dynamic programming makes for an algorithm with a runtime of only O(N*M), where N and M are the numbers of elements in the two sequences.

Conclusion
The different algorithms that people study are as varied as the problems that they solve. However, chances are good that the problem you are trying to solve is similar to another problem in some respects. By developing a good understanding of a large range of algorithms, you will be able to choose the right one for a problem and apply it properly. Furthermore, solving problems like those found in TopCoder's competitions will help you to hone your skills in this respect. Many of the problems, though they may not seem realistic, require the same set of algorithmic knowledge that comes up every day in the real world.


Courtesy
TopCoder

Introduction
The first step towards an understanding of why the study and knowledge of algorithms are so important is to define exactly what we mean by an algorithm. According to the popular algorithms textbook Introduction to Algorithms (Second Edition by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein), "an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values as output." In other words, algorithms are like road maps for accomplishing a given, well-defined task. So, a chunk of code that calculates the terms of the Fibonacci sequence is an implementation of a particular algorithm. Even a simple function for adding two numbers is an algorithm in a sense, albeit a simple one.

Some algorithms, like those that compute the Fibonacci sequences, are intuitive and may be innately embedded into our logical thinking and problem solving skills. However, for most of us, complex algorithms are best studied so we can use them as building blocks for more efficient logical problem solving in the future. In fact, you may be surprised to learn just how many complex algorithms people use every day when they check their e-mail or listen to music on their computers. This article will introduce some basic ideas related to the analysis of algorithms, and then put these into practice with a few examples illustrating why it is important to know about algorithms.

Runtime Analysis
One of the most important aspects of an algorithm is how fast it is. It is often easy to come up with an algorithm to solve a problem, but if the algorithm is too slow, it's back to the drawing board. Since the exact speed of an algorithm depends on where the algorithm is run, as well as the exact details of its implementation, computer scientists typically talk about the runtime relative to the size of the input. For example, if the input consists of N integers, an algorithm might have a runtime proportional to N2, represented as O(N2). This means that if you were to run an implementation of the algorithm on your computer with an input of size N, it would take C*N2 seconds, where C is some constant that doesn't change with the size of the input.

However, the execution time of many complex algorithms can vary due to factors other than the size of the input. For example, a sorting algorithm may run much faster when given a set of integers that are already sorted than it would when given the same set of integers in a random order. As a result, you often hear people talk about the worst-case runtime, or the average-case runtime. The worst-case runtime is how long it would take for the algorithm to run if it were given the most insidious of all possible inputs. The average-case runtime is the average of how long it would take the algorithm to run if it were given all possible inputs. Of the two, the worst-case is often easier to reason about, and therefore is more frequently used as a benchmark for a given algorithm. The process of determining the worst-case and average-case runtimes for a given algorithm can be tricky, since it is usually impossible to run an algorithm on all possible inputs. There are many good online resources that can help you in estimating these values.

Approximate completion time for algorithms, N = 100
O(Log(N)) 10-7 seconds
O(N) 10-6 seconds
O(N*Log(N)) 10-5 seconds
O(N2) 10-4 seconds
O(N6) 3 minutes
O(2N) 1014 years.
O(N!) 10142 years.

Sorting
Sorting provides a good example of an algorithm that is very frequently used by computer scientists. The simplest way to sort a group of items is to start by removing the smallest item from the group, and put it first. Then remove the next smallest, and put it next and so on. Unfortunately, this algorithm is O(N2), meaning that the amount of time it takes is proportional to the number of items squared. If you had to sort a billion things, this algorithm would take around 1018 operations. To put this in perspective, a desktop PC can do a little bit over 109 operations per second, and would take years to finish sorting a billion things this way.

Luckily, there are a number of better algorithms (quicksort, heapsort and mergesort, for example) that have been devised over the years, many of which have a runtime of O(N * Log(N)). This brings the number of operations required to sort a billion items down to a reasonable number that even a cheap desktop could perform. Instead of a billion squared operations (1018) these algorithms require only about 10 billion operations (1010), a factor of 100 million faster.

Shortest Path
Algorithms for finding the shortest path from one point to another have been researched for years. Applications abound, but lets keep things simple by saying we want to find the shortest path from point A to point B in a city with just a few streets and intersections. There are quite a few different algorithms that have been developed to solve such problems, all with different benefits and drawbacks. Before we delve into them though, lets consider how long a naive algorithm - one that tries every conceivable option - would take to run. If the algorithm considered every possible path from A to B (that didn't go in circles), it would not finish in our lifetimes, even if A and B were both in a small town. The runtime of this algorithm is exponential in the size of the input, meaning that it is O(CN) for some C. Even for small values of C, CN becomes astronomical when N gets even moderately large.

One of the fastest algorithms for solving this problem has a runtime of O(E*V*Log(V)), where E is the number of road segments, and V is the number of intersections. To put this in perspective, the algorithm would take about 2 seconds to find the shortest path in a city with 10,000 intersections, and 20,000 road segments (there are usually about 2 road segments per intersection). The algorithm, known as Djikstra's Algorithm, is fairly complex, and requires the use of a data structure known as a priority queue. In some applications, however, even this runtime is too slow (consider finding the shortest path from New York City to San Francisco - there are millions of intersections in the US), and programmers try to do better by using what are known as heuristics. A heuristic is an approximation of something that is relevant to the problem, and is often computed by an algorithm of its own. In the shortest path problem, for example, it is useful to know approximately how far a point is from the destination. Knowing this allows for the development of faster algorithms (such as A*, an algorithm that can sometimes run significantly faster than Djikstra's algorithm) and so programmers come up with heuristics to approximate this value. Doing so does not always improve the runtime of the algorithm in the worst case, but it does make the algorithm faster in most real-world applications.

Approximate algorithms
Sometimes, however, even the most advanced algorithm, with the most advanced heuristics, on the fastest computers is too slow. In this case, sacrifices must be made that relate to the correctness of the result. Rather than trying to get the shortest path, a programmer might be satisfied to find a path that is at most 10% longer than the shortest path.

In fact, there are quite a few important problems for which the best-known algorithm that produces an optimal answer is insufficiently slow for most purposes. The most famous group of these problems is called NP, which stands for non-deterministic polynomial (don't worry about what that means). When a problem is said to be NP-complete or NP-hard, it mean no one knows a good way to solve them optimally. Furthermore, if someone did figure out an efficient algorithm for one NP-hard problem, that algorithm would be applicable to all NP-hard problems.

A good example of an NP-hard problem is the famous traveling salesman problem. A salesman wants to visit N cities, and he knows how long it takes to get from each city to each other city. The question is "how fast can he visit all of the cities?" Since the fastest known algorithm for solving this problem is too slow - and many believe this will always be true - programmers look for sufficiently fast algorithms that give good, but not optimal solutions.

Random Algorithms
Yet another approach to some problems is to randomize an algorithm is some way. While doing so does not improve the algorithm in the worst case, it often makes very good algorithms in the average case. Quicksort is a good example of an algorithm where randomization is often used. In the worst case, quicksort sorts a group of items in O(N2), where N is the number of items. If randomization is incorporated into the algorithm, however, the chances of the worst case actually occurring become diminishingly small, and on average, quicksort has a runtime of O(N*Log(N)). Other algorithms guarantee a runtime of O(N*Log(N)), even in the worst case, but they are slower in the average case. Even though both algorithms have a runtime proportional to N*Log(N), quicksort has a smaller constant factor - that is it requires C*N*Log(N) operations, while other algorithms require more like 2*C*N*Log(N) operations.

Another algorithm that uses random numbers finds the median of a group of numbers with an average runtime of O(N). This is a significant improvement over sorting the numbers and taking the middle one, which takes O(N*Log(N)). Furthermore, while deterministic (non-random) algorithms exist for finding the median with a runtime of O(N), the random algorithm is attractively simple, and often faster than the deterministic algorithms.

The basic idea of the median algorithm is to pick one of the numbers in the group at random, and count how many of the numbers in the group are less than it. Lets say there are N numbers, and K of them are less than or equal to the number we picked at random. If K is less than half of N, then we know that the median is the (N/2-K) th number that is greater than the random number we picked, so we discard the K numbers less than or equal to the random number. Now, we want to find the (N/2-K) th smallest number, instead of the median. The algorithm is the same though, and we simply pick another number at random, and repeat the above steps.

Compression
Another class of algorithm deals with situations such as data compression. This type of algorithm does not have an expected output (like a sorting algorithm), but instead tries to optimize some other criteria. In the case of data compression, the algorithm (LZW, for instance) tries to make the data use as few bytes as possible, in such a way that it can be decompressed to its original form. In some cases, this type of algorithm will use the same techniques as other algorithms, resulting in output that is good, but potentially sub-optimal. JPG and MP3 compression, for example, both compress data in a way that makes the final result somewhat lower quality than the original, but they create much smaller files. MP3 compression does not retain every feature of the original song file, but it attempts to maintain enough of the details to capture most of the quality, while at the same time ensuring the significantly reduced file size that we all know and love. The JPG image file format follows the same principle, but the details are significantly different since the goal is image rather than audio compression.

The Importance of Knowing Algorithms
As a computer scientist, it is important to understand all of these types of algorithms so that one can use them properly. If you are working on an important piece of software, you will likely need to be able to estimate how fast it is going to run. Such an estimate will be less accurate without an understanding of runtime analysis. Furthermore, you need to understand the details of the algorithms involved so that you'll be able to predict if there are special cases in which the software won't work quickly, or if it will produce unacceptable results.

Of course, there are often times when you'll run across a problem that has not been previously studied. In these cases, you have to come up with a new algorithm, or apply an old algorithm in a new way. The more you know about algorithms in this case, the better your chances are of finding a good way to solve the problem. In many cases, a new problem can be reduced to an old problem without too much effort, but you will need to have a fundamental understanding of the old problem in order to do this.

As an example of this, lets consider what a switch does on the Internet. A switch has N cables plugged into it, and receives packets of data coming in from the cables. The switch has to first analyze the packets, and then send them back out on the correct cables. A switch, like a computer, is run by a clock with discrete steps - the packets are send out at discrete intervals, rather than continuously. In a fast switch, we want to send out as many packets as possible during each interval so they don't stack up and get dropped. The goal of the algorithm we want to develop is to send out as many packets as possible during each interval, and also to send them out so that the ones that arrived earlier get sent out earlier. In this case it turns out that an algorithm for a problem that is known as "stable matching" is directly applicable to our problem, though at first glance this relationship seems unlikely. Only through pre-existing algorithmic knowledge and understanding can such a relationship be discovered.

More Real-world Examples
Other examples of real-world problems with solutions requiring advanced algorithms abound. Almost everything that you do with a computer relies in some way on an algorithm that someone has worked very hard to figure out. Even the simplest application on a modern computer would not be possible without algorithms being utilized behind the scenes to manage memory and load data from the hard drive.

There are dozens of applications of complicated algorithms, but I'm going to discuss two problems that require the same skills as some past TopCoder problems. The first is known as the maximum flow problem, and the second is related to dynamic programming, a technique that often solves seemingly impossible problems in blazing speed.

Maximum Flow
The maximum flow problem has to do with determining the best way to get some sort of stuff from one place to another, through a network of some sort. In more concrete terms, the problem first arose in relation to the rail networks of the Soviet Union, during the 1950's. The US wanted to know how quickly the Soviet Union could get supplies through its rail network to its satellite states in Eastern Europe.

In addition, the US wanted to know which rails it could destroy most easily to cut off the satellite states from the rest of the Soviet Union. It turned out that these two problems were closely related, and that solving the max flow problem also solves the min cut problem of figuring out the cheapest way to cut off the Soviet Union from its satellites.

The first efficient algorithm for finding the maximum flow was conceived by two Computer Scientists, named Ford and Fulkerson. The algorithm was subsequently named the Ford-Fulkerson algorithm, and is one of the more famous algorithms in computer science. In the last 50 years, a number of improvements have been made to the Ford-Fulkerson algorithm to make it faster, some of which are dauntingly complex.

Since the problem was first posed, many additional applications have been discovered. The algorithm has obvious relevance to the Internet, where getting as much data as possible from one point to another is important. It also comes up in many business settings, and is an important part of operations research. For example, if you have N employees and N jobs that need to be done, but not every employee can do every job, the max flow algorithm will tell you how to assign your N employees to jobs in such a way that every job gets done, provided that's possible. Graduation, from SRM 200, is a good example of a TopCoder problem that lends itself to a solution using max flow.

Sequence comparison
Many coders go their entire careers without ever having to implement an algorithm that uses dynamic programming. However, dynamic programming pops up in a number of important algorithms. One algorithm that most programmers have probably used, even though they may not have known it, finds differences between two sequences. More specifically, it calculates the minimum number of insertions, deletions, and edits required to transform sequence A into sequence B.

For example, lets consider two sequences of letters, "AABAA" and "AAAB". To transform the first sequence into the second, the simplest thing to do is delete the B in the middle, and change the final A into a B. This algorithm has many applications, including some DNA problems and plagiarism detection. However, the form in which many programmers use it is when comparing two versions of the same source code file. If the elements of the sequence are lines in the file, then this algorithm can tell a programmer which lines of code were removed, which ones were inserted, and which ones were modified to get from one version to the next.

Without dynamic programming, we would have to consider a - you guessed it - exponential number of transformations to get from one sequence to the other. As it is, however, dynamic programming makes for an algorithm with a runtime of only O(N*M), where N and M are the numbers of elements in the two sequences.

Conclusion
The different algorithms that people study are as varied as the problems that they solve. However, chances are good that the problem you are trying to solve is similar to another problem in some respects. By developing a good understanding of a large range of algorithms, you will be able to choose the right one for a problem and apply it properly. Furthermore, solving problems like those found in TopCoder's competitions will help you to hone your skills in this respect. Many of the problems, though they may not seem realistic, require the same set of algorithmic knowledge that comes up every day in the real world.


Courtesy
TopCoder

 

A human Language - AIML

Category: , By Mourya
When i first used ALICE in my 6th grade, i was mesmerized with the response it gave to every question i posted.I used to chat with it for hours and hours...I noticed that it used to respond same way for question in different ways.I wondered because i knew at that time it was a program and programs are not capable for thinking on there own.Then after months i found some glitches when i posted weird question.It used to something else.Soon i got bored of it and stopped playing with it.After 8 years i found out that there are ways to make a program or in fact a bot which can logically answer the question though the syntax is different.Welcome to the world of AIML

* What is AIML?
AIML stands for Artificial Intelligence Markup Language , a dialect of the noted XML family.

* The History

The XML dialect called AIML was developed by Richard Wallace and a worldwide free software community between the years of 1995 and 2002. It formed the basis for what was initially a highly extended Eliza called "A.L.I.C.E." ("Artificial Linguistic Internet Computer Entity"), which won the annual Loebner Prize Contest for Most Human Computer three times, and was also the Chatterbox Challenge Champion in 2004.

* Structure

A AIML basically consists of categories and templates.Categories in AIML are the fundamental unit of knowledge. A category consists of at least two further elements: the pattern and template elements.

An example of a category


WHAT IS THE TIME



When this category is loaded, an AIML bot will respond to the input "What is the time" with response "The time is 9 o'clock.


* Pattern

A pattern is a string of characters intended to match one or more user inputs. A literal pattern like
WHAT IS YOUR NAME
will match only one input, ignoring case: "what is your name". But patterns may also contain wildcards, which match one or more words. A pattern like
WHAT IS YOUR *
will match an infinite number of inputs, including "what is your name", "what is your shoe size", "what is your purpose in life", etc.
The AIML pattern syntax is a very simple pattern language, far less complicated than regular expressions. It tends to suffice for most chat-oriented purposes, and where it lacks, AIML interpreters can provide preprocessing functions to expand abbreviations, remove misspellings, etc.

* Template

A template specifies the response to a matched pattern. A template may be as simple as some literal text, like
My name is Mourya.
A template may use variables, such as the example
My name is .
which will substitute the bot's name into the sentence, or
You told me you are years old.
which will substitute the user's age (if known) into the sentence.
Template elements include basic text formatting, conditional response (if-then/else), and random responses.

So in future expect lots of development in AIML.

For an AIML File creator click here

When i first used ALICE in my 6th grade, i was mesmerized with the response it gave to every question i posted.I used to chat with it for hours and hours...I noticed that it used to respond same way for question in different ways.I wondered because i knew at that time it was a program and programs are not capable for thinking on there own.Then after months i found some glitches when i posted weird question.It used to something else.Soon i got bored of it and stopped playing with it.After 8 years i found out that there are ways to make a program or in fact a bot which can logically answer the question though the syntax is different.Welcome to the world of AIML

* What is AIML?
AIML stands for Artificial Intelligence Markup Language , a dialect of the noted XML family.

* The History

The XML dialect called AIML was developed by Richard Wallace and a worldwide free software community between the years of 1995 and 2002. It formed the basis for what was initially a highly extended Eliza called "A.L.I.C.E." ("Artificial Linguistic Internet Computer Entity"), which won the annual Loebner Prize Contest for Most Human Computer three times, and was also the Chatterbox Challenge Champion in 2004.

* Structure

A AIML basically consists of categories and templates.Categories in AIML are the fundamental unit of knowledge. A category consists of at least two further elements: the pattern and template elements.

An example of a category


WHAT IS THE TIME



When this category is loaded, an AIML bot will respond to the input "What is the time" with response "The time is 9 o'clock.


* Pattern

A pattern is a string of characters intended to match one or more user inputs. A literal pattern like
WHAT IS YOUR NAME
will match only one input, ignoring case: "what is your name". But patterns may also contain wildcards, which match one or more words. A pattern like
WHAT IS YOUR *
will match an infinite number of inputs, including "what is your name", "what is your shoe size", "what is your purpose in life", etc.
The AIML pattern syntax is a very simple pattern language, far less complicated than regular expressions. It tends to suffice for most chat-oriented purposes, and where it lacks, AIML interpreters can provide preprocessing functions to expand abbreviations, remove misspellings, etc.

* Template

A template specifies the response to a matched pattern. A template may be as simple as some literal text, like
My name is Mourya.
A template may use variables, such as the example
My name is .
which will substitute the bot's name into the sentence, or
You told me you are years old.
which will substitute the user's age (if known) into the sentence.
Template elements include basic text formatting, conditional response (if-then/else), and random responses.

So in future expect lots of development in AIML.

For an AIML File creator click here

 

Google Chrome - A personal Feel

Category: , By Mourya



It has been nearly 48 hours since the release of Google Browser Chrome...Actually there was hardly any publicity by the company.

The downloading was very simple.Took me around 15 minutes to complete.As soon as i started the browser it prompted me to import user data from Firefox and IE.

From the 4 hours browsing i did , few things i have noticed is

* It comes with the default plugins for active x and flash player.
* Doesn't have a title bar( guess Google people want users to encourage reading source)
* And the new Omni bar ( Address bar + Google Search Bar).It doesn't support favicons (though the tabs support them)
* The tabs are provided instead of the title bar.And there is no mention of Google anywhere in the layout of the browser.

Coming to Browsing Experience,chrome steals the show because of its clean , simple and faster capacity to render the web pages.

Incognito Mode

Chrome has a new addition called the Incognito mode which when activated doesnt include the web pages we viewed in the history(might be helpful for teens to view porn without getting caught ).

Final Verdict is that Chrome is in a way Firefox in new avatar.


To download the Chrome click here




It has been nearly 48 hours since the release of Google Browser Chrome...Actually there was hardly any publicity by the company.

The downloading was very simple.Took me around 15 minutes to complete.As soon as i started the browser it prompted me to import user data from Firefox and IE.

From the 4 hours browsing i did , few things i have noticed is

* It comes with the default plugins for active x and flash player.
* Doesn't have a title bar( guess Google people want users to encourage reading source)
* And the new Omni bar ( Address bar + Google Search Bar).It doesn't support favicons (though the tabs support them)
* The tabs are provided instead of the title bar.And there is no mention of Google anywhere in the layout of the browser.

Coming to Browsing Experience,chrome steals the show because of its clean , simple and faster capacity to render the web pages.

Incognito Mode

Chrome has a new addition called the Incognito mode which when activated doesnt include the web pages we viewed in the history(might be helpful for teens to view porn without getting caught ).

Final Verdict is that Chrome is in a way Firefox in new avatar.


To download the Chrome click here

 

Chapter 1-6

By Mourya
1.Structure of BF

The BF language is actually made of an array of size 30,000.Each cell occupies one byte,so its range is actually from 0-255.

[0][4][67][1][55][255][23][0]
^
So the ^ symbol actually indicates the present location in the program.

2.The Operators

The basic idea behind brainfuck is memory manipulation.Brain fuck has only 8 operators that are all written in single characters.Even though BF is restricted to these 8 characters and strictly restrictive any program that can be written in c can be written in brain fuck.

The eight operators are

* + increase byte under pointer
* - decrease byte under pointer
* > increase pointer
* < decrease pointer
* [ start a loop if byte under pointer is not 0
* ] return to matching [
* . print byte under pointer to standard output (often screen)
* , read input from standard input (often keyboard) to byte under pointer

3.The Arithematic calculations

1.Addition
2.Subtraction
3.Multiplication
4.Division

1.Structure of BF

The BF language is actually made of an array of size 30,000.Each cell occupies one byte,so its range is actually from 0-255.

[0][4][67][1][55][255][23][0]
^
So the ^ symbol actually indicates the present location in the program.

2.The Operators

The basic idea behind brainfuck is memory manipulation.Brain fuck has only 8 operators that are all written in single characters.Even though BF is restricted to these 8 characters and strictly restrictive any program that can be written in c can be written in brain fuck.

The eight operators are

* + increase byte under pointer
* - decrease byte under pointer
* > increase pointer
* < decrease pointer
* [ start a loop if byte under pointer is not 0
* ] return to matching [
* . print byte under pointer to standard output (often screen)
* , read input from standard input (often keyboard) to byte under pointer

3.The Arithematic calculations

1.Addition
2.Subtraction
3.Multiplication
4.Division

 

My First Experience wid Brain FCUK

Category: By Mourya
So in the last posting i wrote an intro regarding whats a BF and n how much time it takes to try it.Now its time to try the basics

So the index can be divided into
1.Structure of BF
2.The Operators
3.Ari thematic calculations
4.Loops
5.Your first step
6.If statements
7.Interpretor

So in the last posting i wrote an intro regarding whats a BF and n how much time it takes to try it.Now its time to try the basics

So the index can be divided into
1.Structure of BF
2.The Operators
3.Ari thematic calculations
4.Loops
5.Your first step
6.If statements
7.Interpretor

 

Brain FCUK----A three Day Guide

Category: By Mourya
Day 1.


Few days back when my senior told me about Saastra conducted in IITM,I was little excited.Even the guy who told was pretty excited.So i checked out their website (Which was pretty decent and informative),but was really disappointed because most of the contest are out of scope to participate.Last year when i participated for few tech events at mah place,i had n urge to participate in any events conducted in any of the IIT's.But checking the events brought me to the reality.These IIT ppl set themselves a standard and expect the people to be in par with them.But most of the ppl in out college are still sticking with the roots and squares with c and c++.And coming back the events mainly dealt with projects.So i checked all the events.One Event which caught my attention was Brain Fuck.So i checked the details of the contest.It said that its actually a name of an esoteric programming language noted for its extreme minimalism.

I checked the four problems given for the qualification round.The first thing i felt was these problems were very easy to solve in C.So I thought why don't i give a try to solve these problems.But the first constrain was i hardly know what this brain fuck program looks like , Where and how these programs can be written.


So after a bit googling i found an interpreter and few tutorials covering the basics of this programing.After studying the basics i thought why don't i start a program.
As everyone starts with printing something(Usually Hello World) .I though of printing the same statement in BF(Short for Brain Fuck).Luckily the tutorial i checked previously had this program .So i copied it and pasted it in the interpreter.
And wow i got the result.Next thing was understanding how it actually printed.
I was shocked to find that this printing which actually takes a line in C language actually took me 2 hours to understand and 6 lines of code!!!

The next thing i did was go out had some junkies and came back in the evening.
Did a bit of orkuting and went to sleep.


Day 2.
Next morning i forgot about the bf and was browsing when i thought of giving it an another try.This time i did the basics like moving from one location to another and back.Finally by the end of the day i was able to do calculate sum,division and multiplication.I was even able to move a number from one location to another( gr8 going).



Day 3.
Finally after waking up in the morning i thought of starting to work on the Event problems.The first thing i noticed was those problems which were very easy to solve in C were damn fucking in BF(Guess its the reason why the author took the name).
However by the evening i solved three out of the four.
In the next posting ill b writing the introduction and basics of BF.Till then have a gr8 BF

Day 1.


Few days back when my senior told me about Saastra conducted in IITM,I was little excited.Even the guy who told was pretty excited.So i checked out their website (Which was pretty decent and informative),but was really disappointed because most of the contest are out of scope to participate.Last year when i participated for few tech events at mah place,i had n urge to participate in any events conducted in any of the IIT's.But checking the events brought me to the reality.These IIT ppl set themselves a standard and expect the people to be in par with them.But most of the ppl in out college are still sticking with the roots and squares with c and c++.And coming back the events mainly dealt with projects.So i checked all the events.One Event which caught my attention was Brain Fuck.So i checked the details of the contest.It said that its actually a name of an esoteric programming language noted for its extreme minimalism.

I checked the four problems given for the qualification round.The first thing i felt was these problems were very easy to solve in C.So I thought why don't i give a try to solve these problems.But the first constrain was i hardly know what this brain fuck program looks like , Where and how these programs can be written.


So after a bit googling i found an interpreter and few tutorials covering the basics of this programing.After studying the basics i thought why don't i start a program.
As everyone starts with printing something(Usually Hello World) .I though of printing the same statement in BF(Short for Brain Fuck).Luckily the tutorial i checked previously had this program .So i copied it and pasted it in the interpreter.
And wow i got the result.Next thing was understanding how it actually printed.
I was shocked to find that this printing which actually takes a line in C language actually took me 2 hours to understand and 6 lines of code!!!

The next thing i did was go out had some junkies and came back in the evening.
Did a bit of orkuting and went to sleep.


Day 2.
Next morning i forgot about the bf and was browsing when i thought of giving it an another try.This time i did the basics like moving from one location to another and back.Finally by the end of the day i was able to do calculate sum,division and multiplication.I was even able to move a number from one location to another( gr8 going).



Day 3.
Finally after waking up in the morning i thought of starting to work on the Event problems.The first thing i noticed was those problems which were very easy to solve in C were damn fucking in BF(Guess its the reason why the author took the name).
However by the evening i solved three out of the four.
In the next posting ill b writing the introduction and basics of BF.Till then have a gr8 BF