Thursday, October 31, 2013

Data Structures

 
Algorithms +Data Structures = Programs
 
We often see that the concept of Data Structures is explained along with Algorithms. Have you ever wondered why? It is because, the underlying data structure of an algorithm plays an important role in determining the performance of the algorithm. So let us see what a data structure is and how it effects the performance of algorithms.
Data structure, as the name indicates is a particular way of storing and organizing data in a computer program. The definition looks good, but why do we use data structures? Suppose you are writing a computer program to store all the student information of your university. For that you have to store a lot information such as student name, ID, department, courses taken, grades, etc. Once you have all the information, you may want to know how many students enrolled in a particular course.  What is the average class standing in a particular course? What is the current GPA of a particular student? By just looking at the information you may not be able to answer such questions.  The data/information must be organized in such a way that one should be able to retrieve the data, perform some calculations on the data and find answers to their questions. This is where data structures come in.
Data structure should be designed/chosen in such a way that storing and retrieving of data is fast. Most computer programs deal with hundreds of thousands of data records. If you choose an improper data structure to store your data, retrieving a single record from thousands of records could take a lot of time and as you know, for a computer program, even a couple of seconds is a lot of time. So, choosing a wrong data structure makes your program slow (I told you! The choice of data structure affects the performance of an algorithm.)

1 comment:

  1. Hi Usha,
    Great post about data structures! Good examples of what you would need data structures for. One thing you need to fix is in the first paragraph, last sentence, " So let us see what a data structure is and how it how it effects the performance of algorithms.", you have how it how it twice. You might want to run each of your post through criterion. I did and I really helped me revise my posts. It would have been nice if you included some actual data structures that you could implement for that example. Other than that, great post and keep it up!

    ReplyDelete