Data Structure is simply a way of organizing and storing our data so that the data can be accessed and used in an efficient manner.
As Programmers, having a strong foundation for data structures is crucial, as to how we store our data has in turn great impact on the performance of the programs. A Code is considered to be a Good code if it is-
- Manageable and
Readability and Maintainability come from following best practices and conventions like Naming, Indentation, Documentation, etc, but Scalability is determined using two factors- Time Complexity and Space Complexity.
Time Complexity refers to the amount of time and Space Complexity refers to the amount of space that is required to run an algorithm. Time is precious and memory is limited. Data that is stored in a haphazard manner will take longer to access and will slow down the program. So structuring our data as per the requirement is crucial as it capaciously affects the time and space complexity of the programs.
NOTE — Time and Space Complexity is approximately calculated with the help of Big-O Notation (will be discussed in upcoming articles).
Data structures are primarily of two types-
- Linear data structures
- Non-linear data structures
The data structure in which the data is stored in a sequential manner, one after the other is known as a Linear data structure. Traversing (moving from one data item to another) can be done in a single run. Example- Linked Lists, Stacks, Queues, Arrays, etc, and
The data structure in which the data is stored in a non-sequential manner is known as a Non-linear data structure. Traversing can’t be done in a single run. Example- Trees and Graphs.
There are various operations that can be performed on data structures like-
- Access- grabbing the value of a data item.
- Append- adding items to the end.
- Prepend- adding items to the beginning.
- Insertion- adding items at a particular position.
- Deletion- removing items from a particular position.
- Traversing- moving from one item to another.
- Searching- checking the presence of a particular item.
- Sorting- arranging the data items in a particular order.
In the upcoming articles, we will be discussing and implementing some of the important data structures.