Photo by Susan Q Yin on Unsplash
Data Structures - What is that?
Simple explanatory guide to data structures.
Imagine, you went to a library and want to read a book written by H. G. Wells. You started hunting for the book from the first book shell till the end the of library and by the way, the library is way bigger than it would take you to find the book of more than a day or two. You are just creeped out by the idea of finding the book for that long and returning home. Suddenly, there is the voice of the person who calls you back and asks about your need and then acts on them. The person gets into the library and points out the author that you were looking for in little to no time. You are just astounded by the fact that the person was able to do that in an efficient way.
You wondered whether he is a magician or something. But when the person also known as a Librarian tells you that the books are arranged in such a way that they can be accessible with little less effort because the librarian used some sort of structure in his computer by which the librarian was able to get to the requirements.
This is what we called Data Structures as we organize, manage and store them in a way that the data can be accessed efficiently.
Introduction
Data structures are the ability of a system/computer to fetch and store data at any place in its memory specified by a pointer--a bit string, representing a memory address, that can be itself stored in memory and manipulated by the program.
The implementation of a data structure usually requires writing a set of procedures that create and manipulate instances of that structure. The efficiency of a data structure cannot be analyzed separately from those operations. This observation motivates the theoretical concept of an abstract data types. Let's get into it.
Data Type vs Data Structures
The data type is the form of a variable to which a value can be assigned. It defines that the particular variable will assign the values of the given data type only. It can hold values but not data (dataless). The implementation is known as abstract implementation. There is no time complexity in the case of data types. It only represents the type of data that can be stored. (Ex. Primitive- int, boolean, char, double, byte, short, long, float. Non-Primitive- Arrays, Strings and Classes, etc.)
The data structure is a collection of different kinds of data. That entire data can be represented using an object and can be used throughout the program. It can store multiple types of data within a single object. It has a concrete implementation. Time complexity plays an important role. The data and its value acquire the space in the computer's main memory with different kinds of data within one single object. (Ex. Arrays, LinkedList, Stacks, Queues, Hash Tables, Trees, Heaps, Graphs, etc.)
Classification of data structures
The data structure is divided into two parts:
1. Linear Data Structures
It is a type of data structure where the arrangement of the data follows a linear trend. The data elements are arranged linearly such that the element is directly linked to its previous and the next elements. As the elements are stored linearly, the structure supports single-level storage of data. And hence, traversal of the data is achieved through a single run only.