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.)