Sunday, September 30, 2012

Why study Data Structures??


Most of us who study data structures in the 3rd semester, always wonder where is data structures used after all??
Except the most basic ones like Arrays, we are never ever able to understand where is it that we use these so complex data structures and is it important from an interview perspective.?? Well, let me tell you, it is one of the most asked topics in an interview and every good technology company will must and should ask you about it. This brings us to our next question, what is it that makes it so important?? Here is why:- For any program to run, it needs data and this data needs to be in primary memory, what we generally call as RAM. The way we organize data in this memory is data structures. I know you must be thinking, what would happen if I don't arrange this data? I can still access the memory and get the data. Yes, you are surely right, you can get the data but it might take much longer to retrieve it. A real life analogy to it would be to search for something in a messy room like the one shown.
You would obviously find it easy to find things in a room like the one on right. I do agree that maintaining a room like the one on right requires lot of efforts but trust me in technology it is surely worth its cost.
There are a few more technicalities like, the time needed to access a cache, RAM, Hard Disk drive increases in that order. Hence you need to make as less possible access to hard disk as you can. A practical example for this would be: assume you are asked to get something from a shop. You would first try to visit a shop as close to your house though he might charge you a little more, if not found there you would go to a super market, if not found there as well you would finally end up at the main market. Very similar to this is how a cache, RAM, hard disk works. The cache access time is very less and hence it is more costlier than the rest. For those of us who confuse data structures with DBMS, a very short explaination would be that DBMS is about storing data on your hard disk where as data structures is all about how to organize data on RAM. In the coming days, we will take up individual data structures and see where they fit and when is it that they are best used.